aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/popupmenu.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/nvim/popupmenu.c b/src/nvim/popupmenu.c
index 953d2e75a6..8bf145f520 100644
--- a/src/nvim/popupmenu.c
+++ b/src/nvim/popupmenu.c
@@ -941,11 +941,14 @@ static bool pum_set_selected(int n, int repeat)
pum_selected = n;
unsigned cur_cot_flags = get_cot_flags();
bool use_float = (cur_cot_flags & kOptCotFlagPopup) != 0;
- // when new leader add and info window is shown and no selected we still
- // need use the first index item to update the info float window position.
- bool force_select = use_float && pum_selected < 0 && win_float_find_preview();
- if (force_select) {
- pum_selected = 0;
+
+ // Close the floating preview window if 'selected' is -1, indicating a return to the original
+ // state. It is also closed when the selected item has no corresponding info item.
+ if (use_float && (pum_selected < 0 || pum_array[pum_selected].pum_info == NULL)) {
+ win_T *wp = win_float_find_preview();
+ if (wp) {
+ win_close(wp, true, true);
+ }
}
if ((pum_selected >= 0) && (pum_selected < pum_size)) {
@@ -1164,11 +1167,6 @@ static bool pum_set_selected(int n, int repeat)
}
}
- // restore before selected value
- if (force_select) {
- pum_selected = n;
- }
-
return resized;
}