]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1960: Wrong position of info popup v9.1.1960
authorglepnir <glephunter@gmail.com>
Sun, 7 Dec 2025 17:54:26 +0000 (18:54 +0100)
committerChristian Brabandt <cb@256bit.org>
Sun, 7 Dec 2025 18:06:20 +0000 (19:06 +0100)
Problem:  When the popup menu is displayed above the cursor and the
          selected item has no room below for the info popup,
          popup_adjust_position() places the popup in the available
          space above. The calculation added some extra lines, causing
          the popup to be misaligned.
Solution: For info popups, undo that extra spacing so the popup stays
          aligned with the selected item (glepnir)

closes: #18860

Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/popupwin.c
src/testdir/dumps/Test_popupwin_infopopup_align_item_01.dump [new file with mode: 0644]
src/testdir/test_popupwin.vim
src/version.c

index 96f669a50c02b70bb6518e07e81a0c9b556e2d5a..b74a9445bbb8c421120d8cc83b2f4ec6dd5467b0 100644 (file)
@@ -1647,6 +1647,8 @@ popup_adjust_position(win_T *wp)
            // make bottom aligned and recompute the height
            wp->w_height = w_height_before_limit;
            wp->w_winrow = wantline - 2 - wp->w_height - extra_height;
+           if (wp->w_popup_flags & POPF_INFO)
+               wp->w_winrow += extra_height + 2;
            if (wp->w_winrow < 0)
            {
                wp->w_height += wp->w_winrow;
diff --git a/src/testdir/dumps/Test_popupwin_infopopup_align_item_01.dump b/src/testdir/dumps/Test_popupwin_infopopup_align_item_01.dump
new file mode 100644 (file)
index 0000000..558a571
--- /dev/null
@@ -0,0 +1,15 @@
+| +0#af5f00255#ffffff0@1|1| | +0#0000000&@70
+| +0#af5f00255&@1|2| | +0#0000000&@70
+| +0#af5f00255&@1|3| | +0#0000000&@70
+| +0#af5f00255&@1|4| | +0#0000000&@70
+| +0#af5f00255&@1|5| | +0#0000000&@70
+| +0#af5f00255&@1|6| | +0#0000000&@70
+| +0#af5f00255&@1|7| | +0#0000000&@70
+| +0#af5f00255&@1|8| | +0#0000000&@14|╔+0#0000001#e0e0e08|═@7|X| +0#0000000#ffffff0@45
+| +0#af5f00255&@1|9| | +0#0000000&@14|║+0#0000001#e0e0e08| |N|i|n|e| @2|║| +0#0000000#ffffff0@45
+| +0#af5f00255&|1|0| +0#0000001#ffd7ff255|c|p|_|m|a|t|c|h|_|a|r@1|a|y| |║+0&#e0e0e08| |T|e|n| @3|║| +0#0000000#ffffff0@45
+| +0#af5f00255&|1@1| +0#0000001#ffd7ff255|c|p|_|s|t|r| @8|║+0&#e0e0e08| |E|l|e|v|e|n| |║| +0#0000000#ffffff0@45
+| +0#af5f00255&|1|2| +0#0000001#e0e0e08|c|p|_|s|c|o|r|e| @6|║| |T|w|e|l|v|e| |║| +0#0000000#ffffff0@45
+| +0#af5f00255&|1|3| |c+0#0000000&|p|_|s|c|o|r|e> @6|╚+0#0000001#e0e0e08|═@7|⇲| +0#0000000#ffffff0@45
+|~+0#4040ff13&| @73
+|-+2#0000000&@1| |O|m|n|i| |c|o|m|p|l|e|t|i|o|n| |(|^|O|^|N|^|P|)| |m+0#00e0003&|a|t|c|h| |3| |o|f| |3| +0#0000000&@34
index 4b616a8a40de6387b3f8c11ce53e7a5b5040f165..a608fbaf596132e7d9b98f83ba359d38b1e237c4 100644 (file)
@@ -3783,6 +3783,38 @@ func Test_popupmenu_info_align_menu()
   call StopVimInTerminal(buf)
 endfunc
 
+func Test_popupmenu_info_align_item()
+  CheckScreendump
+  let lines =<< trim END
+    func Omni_test(findstart, base)
+        if a:findstart
+            return col(".")
+        endif
+        return [
+            \ #{word: "cp_match_array", info: "One\nTwo\nThree\nFour"},
+            \ #{word: "cp_str", info: "Five\nSix\nSeven\nEight"},
+            \ #{word: "cp_score", info: "Nine\nTen\nEleven\nTwelve"},
+            \ ]
+    endfunc
+    set completepopup=border:on,align:item
+    set cot=menu,menuone,popup,
+    set omnifunc=Omni_test
+    set number
+  END
+  call writefile(lines, 'XtestInfoPopupPos', 'D')
+  let buf = RunVimInTerminal('-S XtestInfoPopupPos', #{rows: 15})
+  call TermWait(buf, 25)
+
+  call term_sendkeys(buf, "A"..repeat("\<CR>", 12))
+  call TermWait(buf, 25)
+  call term_sendkeys(buf, "\<C-X>\<C-O>\<C-N>\<C-N>")
+  call TermWait(buf, 25)
+  call VerifyScreenDump(buf, 'Test_popupwin_infopopup_align_item_01', {})
+
+  call term_sendkeys(buf, "\<Esc>")
+  call StopVimInTerminal(buf)
+endfunc
+
 func Test_popupmenu_info_hidden()
   CheckScreendump
   CheckFeature quickfix
index f6133c52d14f6ef42d402c6c96b7fb78766e7936..ba74665b5afd5452c186b58afd2b2f64905a41b1 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1960,
 /**/
     1959,
 /**/