changeset 32202:eae369cd4dcf v9.0.1432

patch 9.0.1432: completion popup in wrong position with virtual text "above" Commit: https://github.com/vim/vim/commit/6ac2e4392a9d8b89c8824bf94a9da24a6f07c74f Author: Bram Moolenaar <Bram@vim.org> Date: Fri Mar 31 19:32:29 2023 +0100 patch 9.0.1432: completion popup in wrong position with virtual text "above" Problem: Completion popup in wrong position with virtual text "above". Solution: Adjust the column. (closes https://github.com/vim/vim/issues/12210)
author Bram Moolenaar <Bram@vim.org>
date Fri, 31 Mar 2023 20:45:05 +0200
parents ac20568109be
children ea636846c2c0
files src/popupmenu.c src/testdir/dumps/Test_ins_complete_popup_position_1.dump src/testdir/test_ins_complete.vim src/version.c
diffstat 4 files changed, 43 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/popupmenu.c
+++ b/src/popupmenu.c
@@ -238,13 +238,16 @@ pum_display(
 	    // cmdline completion popup menu
 	    cursor_col = cmdline_compl_startcol();
 	else
+	{
+	    // w_wcol includes virtual text "above"
+	    int wcol = curwin->w_wcol % curwin->w_width;
 #ifdef FEAT_RIGHTLEFT
-	if (right_left)
-	    cursor_col = curwin->w_wincol + curwin->w_width
-							  - curwin->w_wcol - 1;
-	else
+	    if (right_left)
+		cursor_col = curwin->w_wincol + curwin->w_width - wcol - 1;
+	    else
 #endif
-	    cursor_col = curwin->w_wincol + curwin->w_wcol;
+		cursor_col = curwin->w_wincol + wcol;
+	}
 
 	// if there are more items than room we need a scrollbar
 	if (pum_height < size)
new file mode 100644
--- /dev/null
+++ b/src/testdir/dumps/Test_ins_complete_popup_position_1.dump
@@ -0,0 +1,10 @@
+|o+0&#ffffff0|n|e| @71
+|t|w|o| @71
+|T+0#ffffff16#ff404010|h|e| |q|u|i|c|k| |b|r|o|w|n| |f|o|x| |j|u|m|p|s| |o|v|e|r| |t|h|e| |l|a|z|y| |d|o|g| +0#0000000#ffffff0@31
+|t|h|i|s| |i|s| |l|i|n|e| |f|o|u|r> @57
+|f|o|u|r| @7| +0#0000001#e0e0e08|f|o|u|r| @10| +0#0000000#0000001| +0&#ffffff0@45
+|~+0#4040ff13&| @10| +0#0000001#ffd7ff255|o|n|e| @11| +0#0000000#0000001| +0#4040ff13#ffffff0@45
+|~| @10| +0#0000001#ffd7ff255|t|w|o| @11| +0#0000000#0000001| +0#4040ff13#ffffff0@45
+|~| @10| +0#0000001#ffd7ff255|t|h|i|s| @10| +0#0000000#0000001| +0#4040ff13#ffffff0@45
+|~| @10| +0#0000001#ffd7ff255|i|s| @12| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@45
+|-+2#0000000&@1| |K|e|y|w|o|r|d| |c|o|m|p|l|e|t|i|o|n| |(|^|N|^|P|)| |m+0#00e0003&|a|t|c|h| |1| |o|f| |6| +0#0000000&@33
--- a/src/testdir/test_ins_complete.vim
+++ b/src/testdir/test_ins_complete.vim
@@ -2220,5 +2220,28 @@ func Test_tagfunc_wipes_out_buffer()
   bwipe!
 endfunc
 
+func Test_ins_complete_popup_position()
+  CheckScreendump
+
+  let lines =<< trim END
+      vim9script
+      set nowrap
+      setline(1, ['one', 'two', 'this is line ', 'four'])
+      prop_type_add('test', {highlight: 'Error'})
+      prop_add(3, 0, {
+          text_align: 'above',
+          text: 'The quick brown fox jumps over the lazy dog',
+          type: 'test'
+      })
+  END
+  call writefile(lines, 'XinsPopup', 'D')
+  let buf = RunVimInTerminal('-S XinsPopup', #{rows: 10})
+
+  call term_sendkeys(buf, "3GA\<C-N>")
+  call VerifyScreenDump(buf, 'Test_ins_complete_popup_position_1', {})
+
+  call StopVimInTerminal(buf)
+endfunc
+
 
 " vim: shiftwidth=2 sts=2 expandtab
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1432,
+/**/
     1431,
 /**/
     1430,