vim-patch:9.1.0956: completion may crash, completion highlight wrong with preview window

Problem:  completion may crash, completion highlight wrong with preview
          window (after v9.1.0954)
Solution: correctly calculate scroll offset, check for preview window
          when adding extra highlighting
          (glepnir)

when there have a preview window prepare_tagpreview
will change curwin to preview window and this may cause
ComplMatchIns check condition not correct. check wp is curwin
and also the type of wp is not a preview or poup info

fixes: https://github.com/vim/vim/issues/16284
closes: https://github.com/vim/vim/pull/16283

8d0bb6dc9f
This commit is contained in:
glepnir
2024-12-24 18:12:50 +08:00
committed by zeertzjq
parent a103ec7449
commit 05eca4c04d
5 changed files with 51 additions and 7 deletions

View File

@@ -906,10 +906,10 @@ static bool pum_set_selected(int n, int repeat)
{
bool resized = false;
int context = pum_height / 2;
int scroll_offset = pum_selected - pum_height;
int prev_selected = pum_selected;
pum_selected = n;
int scroll_offset = pum_selected - pum_height;
unsigned cur_cot_flags = get_cot_flags();
bool use_float = (cur_cot_flags & kOptCotFlagPopup) != 0;
@@ -940,7 +940,7 @@ static bool pum_set_selected(int n, int repeat)
// scroll up; when we did a jump it's probably a PageDown then
// scroll a whole page
if (pum_first < scroll_offset + 3) {
pum_first = MAX(pum_first, scroll_offset + 1);
pum_first = MAX(pum_first + pum_height - 2, scroll_offset + 1);
} else {
pum_first = scroll_offset + 1;
}
@@ -953,7 +953,7 @@ static bool pum_set_selected(int n, int repeat)
if (pum_first > pum_selected - context) {
pum_first = MAX(pum_selected - context, 0); // scroll down
} else if (pum_first < pum_selected + context - pum_height + 1) {
pum_first = pum_selected + context - pum_height + 1; // up
pum_first = pum_selected + context - pum_height + 1; // up
}
}
// adjust for the number of lines displayed