patch 9.2.0744: popup_atcursor() closes immediately on white space
Commit:
https://github.com/vim/vim/commit/2c363111ecc03915372ca1ff1e2ccc1656532499
Author: Yasuhiro Matsumoto <
matt...@gmail.com>
Date: Sun Jun 28 18:43:03 2026 +0000
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 <
matt...@gmail.com>
Signed-off-by: Christian Brabandt <
c...@256bit.org>
diff --git a/src/popupwin.c b/src/popupwin.c
index a497ea58c..d30cc33e1 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 5156584e4..7e8fb6233 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\<Esc>", 'xt')
+ call assert_equal(1, popup_getpos(winid).visible)
+ call feedkeys("$i\<Esc>", '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 b76dd5b23..6509e9309 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,
/**/