From: Yasuhiro Matsumoto Date: Sun, 28 Jun 2026 18:43:03 +0000 (+0000) Subject: patch 9.2.0744: popup_atcursor() closes immediately on white space X-Git-Tag: v9.2.0744^0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2c363111ecc03915372ca1ff1e2ccc1656532499;p=thirdparty%2Fvim.git patch 9.2.0744: popup_atcursor() closes immediately on white space Problem: popup_atcursor() closes immediately on white space (Mao-Yining) Solution: Set w_popup_mincol and w_popup_maxcol to the cursor column (Yasuhiro Matsumoto) When the cursor is on white space find_ident_under_cursor() skips forward to the next word, so the moved range did not cover the cursor column and popup_check_cursor_pos() closed the popup right away. Keep the cursor column in that case. fixes: #20652 closes: #20659 Signed-off-by: Yasuhiro Matsumoto Signed-off-by: Christian Brabandt --- diff --git a/src/popupwin.c b/src/popupwin.c index a497ea58ca..d30cc33e17 100644 --- a/src/popupwin.c +++ b/src/popupwin.c @@ -233,12 +233,25 @@ set_moved_columns(win_T *wp, int flags) { char_u *ptr; int len = find_ident_under_cursor(&ptr, flags | FIND_NOERROR); + int mincol; if (len <= 0) return; - wp->w_popup_mincol = (int)(ptr - ml_get_curline()); - wp->w_popup_maxcol = wp->w_popup_mincol + len - 1; + // When the cursor is on white space find_ident_under_cursor() skips + // forward to the next word, whose range does not cover the cursor column. + // Keep the cursor column then, otherwise popup_check_cursor_pos() would + // close the popup right away. + mincol = (int)(ptr - ml_get_curline()); + if (curwin->w_cursor.col < mincol) + { + wp->w_popup_mincol = curwin->w_cursor.col; + wp->w_popup_maxcol = curwin->w_cursor.col; + return; + } + + wp->w_popup_mincol = mincol; + wp->w_popup_maxcol = mincol + len - 1; } /* diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim index 5156584e4f..7e8fb6233d 100644 --- a/src/testdir/test_popupwin.vim +++ b/src/testdir/test_popupwin.vim @@ -2331,6 +2331,20 @@ func Test_popup_moved() call assert_equal({}, popup_getpos(winid)) call popup_clear() + " On white space find_ident_under_cursor() skips forward to the next word, + " whose range does not cover the cursor. The cursor column must be used so + " the popup is not closed right away. + exe "normal gg4|" + let winid = popup_atcursor('text', {}) + redraw + call assert_equal(1, popup_getpos(winid).visible) + call assert_equal([1, 3, 3], popup_getoptions(winid).moved) + call feedkeys("i\", 'xt') + call assert_equal(1, popup_getpos(winid).visible) + call feedkeys("$i\", 'xt') + call assert_equal({}, popup_getpos(winid)) + call popup_clear() + bwipe! call test_override('ALL', 0) endfunc diff --git a/src/version.c b/src/version.c index b76dd5b23b..6509e93096 100644 --- a/src/version.c +++ b/src/version.c @@ -759,6 +759,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 744, /**/ 743, /**/