aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorglepnir <glephunter@gmail.com>2024-12-11 21:20:10 +0800
committerGitHub <noreply@github.com>2024-12-11 05:20:10 -0800
commitff1791c9e59bccaee685a537e094f7d6bdc3b122 (patch)
tree369b82e9dcf68626146c47e2d6c1fdc8aff5e11c /src
parent3dfb9e6f60d9ca27ff140a9300cc1a43e38aa2ee (diff)
downloadrneovim-ff1791c9e59bccaee685a537e094f7d6bdc3b122.tar.gz
rneovim-ff1791c9e59bccaee685a537e094f7d6bdc3b122.tar.bz2
rneovim-ff1791c9e59bccaee685a537e094f7d6bdc3b122.zip
fix(float): close preview float window when no selected #29745
Problem: Float preview window still exist when back at original. Or no info item is selected. Solution: if selected is -1 or no info is selected, if float preview window exist close it first.
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;
}