• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Revisionc5356021a9388faec5e642829f8765e0bec1588c (tree)
Time2022-10-02 22:30:07
AuthorBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Log Message

patch 9.0.0638: popup menu highlight wrong on top of preview popup

Commit: https://github.com/vim/vim/commit/393f8d61f55cb6127a100e812ba4d66097a32d2e
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Oct 2 14:28:30 2022 +0100

patch 9.0.0638: popup menu highlight wrong on top of preview popup
Problem: Popup menu highlight wrong on top of preview popup. (Yegappan
Lakshmanan)
Solution: Also check for the popup menu in screen_line().

Change Summary

Incremental Difference

diff -r 157961d500ff -r c5356021a938 src/screen.c
--- a/src/screen.c Sun Oct 02 14:00:10 2022 +0200
+++ b/src/screen.c Sun Oct 02 15:30:07 2022 +0200
@@ -420,6 +420,27 @@
420420 }
421421
422422 /*
423+ * Return TRUE if the character at "row" / "col" is under the popup menu and it
424+ * will be redrawn soon or it is under another popup.
425+ */
426+ static int
427+skip_for_popup(int row, int col)
428+{
429+ // Popup windows with zindex higher than POPUPMENU_ZINDEX go on top.
430+ if (pum_under_menu(row, col, TRUE)
431+#ifdef FEAT_PROP_POPUP
432+ && screen_zindex <= POPUPMENU_ZINDEX
433+#endif
434+ )
435+ return TRUE;
436+#ifdef FEAT_PROP_POPUP
437+ if (blocked_by_popup(row, col))
438+ return TRUE;
439+#endif
440+ return FALSE;
441+}
442+
443+/*
423444 * Move one "cooked" screen line to the screen, but only the characters that
424445 * have actually changed. Handle insert/delete character.
425446 * "coloff" gives the first column on the screen for this line.
@@ -538,10 +559,10 @@
538559 redraw_this = TRUE;
539560 }
540561 #endif
541-#ifdef FEAT_PROP_POPUP
542- if (blocked_by_popup(row, col + coloff))
562+ // Do not redraw if under the popup menu.
563+ if (redraw_this && skip_for_popup(row, col + coloff))
543564 redraw_this = FALSE;
544-#endif
565+
545566 if (redraw_this)
546567 {
547568 /*
@@ -669,15 +690,11 @@
669690 }
670691 #endif
671692 ScreenAttrs[off_to] = ScreenAttrs[off_from];
672- ScreenCols[off_to] = ScreenCols[off_from];
673693
674694 // For simplicity set the attributes of second half of a
675695 // double-wide character equal to the first half.
676696 if (char_cells == 2)
677- {
678697 ScreenAttrs[off_to + 1] = ScreenAttrs[off_from];
679- ScreenCols[off_to + 1] = ScreenCols[off_from + 1];
680- }
681698
682699 if (enc_dbcs != 0 && char_cells == 2)
683700 screen_char_2(off_to, row, col + coloff);
@@ -2165,17 +2182,8 @@
21652182 return;
21662183
21672184 // Skip if under the popup menu.
2168- // Popup windows with zindex higher than POPUPMENU_ZINDEX go on top.
2169- if (pum_under_menu(row, col, TRUE)
2170-#ifdef FEAT_PROP_POPUP
2171- && screen_zindex <= POPUPMENU_ZINDEX
2172-#endif
2173- )
2185+ if (skip_for_popup(row, col))
21742186 return;
2175-#ifdef FEAT_PROP_POPUP
2176- if (blocked_by_popup(row, col))
2177- return;
2178-#endif
21792187
21802188 // Outputting a character in the last cell on the screen may scroll the
21812189 // screen up. Only do it when the "xn" termcap property is set, otherwise
diff -r 157961d500ff -r c5356021a938 src/testdir/dumps/Test_pum_preview_1.dump
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/testdir/dumps/Test_pum_preview_1.dump Sun Oct 02 15:30:07 2022 +0200
@@ -0,0 +1,12 @@
1+|o+0&#ffffff0|n|e| |o|t|h|e|r> @65
2+|╔+0#0000001#ffd7ff255| |X| +0&#e0e0e08|o|t|h|e|r| @9|═+0&#ffd7ff255@21|X| +0#0000000#ffffff0@32
3+|║+0#0000001#ffd7ff255|l+0#af5f00255&|e| +0#0000001&|o|n|c|e| @32|║| +0#0000000#ffffff0@32
4+|║+0#0000001#ffd7ff255|l+0#af5f00255&|e| +0#0000001&|o|n|l|y| @32|║| +0#0000000#ffffff0@32
5+|║+0#0000001#ffd7ff255|e+0#af5f00255&|c| +0#0000001&|o|f@1| @33|║| +0#0000000#ffffff0@32
6+|║+0#0000001#ffd7ff255|e+0#af5f00255&|c| +0#0000001&|o|n|e| @33|║| +0#0000000#ffffff0@32
7+|║+0#0000001#ffd7ff255|c+0#af5f00255&|a|l@1| +0#0000001&|s+0#00e0e07&|y|s|t|e|m|(+0#e000e06&|'+0#e000002&|e|c|h|o| |h|e|l@1|o|'|)+0#e000e06&| +0#0000001&@14|║| +0#0000000#ffffff0@32
8+|║+0#0000001#ffd7ff255|"+0#0000e05&| |t|h|e| |e|n|d| +0#0000001&@30|║| +0#4040ff13#ffffff0@32
9+|╚+0#0000001#ffd7ff255|═@39|⇲| +0#4040ff13#ffffff0@32
10+|~| @73
11+|~| @73
12+|-+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| |5| +0#0000000&@33
diff -r 157961d500ff -r c5356021a938 src/testdir/dumps/Test_pum_preview_2.dump
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/testdir/dumps/Test_pum_preview_2.dump Sun Oct 02 15:30:07 2022 +0200
@@ -0,0 +1,12 @@
1+|o+0&#ffffff0|n|e| |o|n|c|e> @66
2+|╔+0#0000001#ffd7ff255| |X| |o|t|h|e|r| @9|═@21|X| +0#0000000#ffffff0@32
3+|║+0#0000001#ffd7ff255|l+0#af5f00255&|e| +0#0000001#e0e0e08|o|n|c|e| @10| +0&#ffd7ff255@21|║| +0#0000000#ffffff0@32
4+|║+0#0000001#ffd7ff255|l+0#af5f00255&|e| +0#0000001&|o|n|l|y| @32|║| +0#0000000#ffffff0@32
5+|║+0#0000001#ffd7ff255|e+0#af5f00255&|c| +0#0000001&|o|f@1| @33|║| +0#0000000#ffffff0@32
6+|║+0#0000001#ffd7ff255|e+0#af5f00255&|c| +0#0000001&|o|n|e| @33|║| +0#0000000#ffffff0@32
7+|║+0#0000001#ffd7ff255|c+0#af5f00255&|a|l@1| +0#0000001&|s+0#00e0e07&|y|s|t|e|m|(+0#e000e06&|'+0#e000002&|e|c|h|o| |h|e|l@1|o|'|)+0#e000e06&| +0#0000001&@14|║| +0#0000000#ffffff0@32
8+|║+0#0000001#ffd7ff255|"+0#0000e05&| |t|h|e| |e|n|d| +0#0000001&@30|║| +0#4040ff13#ffffff0@32
9+|╚+0#0000001#ffd7ff255|═@39|⇲| +0#4040ff13#ffffff0@32
10+|~| @73
11+|~| @73
12+|-+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| |2| |o|f| |5| +0#0000000&@33
diff -r 157961d500ff -r c5356021a938 src/testdir/dumps/Test_pum_preview_3.dump
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/testdir/dumps/Test_pum_preview_3.dump Sun Oct 02 15:30:07 2022 +0200
@@ -0,0 +1,12 @@
1+|o+0&#ffffff0|n|e| |o|n|l|y> @66
2+|╔+0#0000001#ffd7ff255| |X| |o|t|h|e|r| @9|═@21|X| +0#0000000#ffffff0@32
3+|║+0#0000001#ffd7ff255|l+0#af5f00255&|e| +0#0000001&|o|n|c|e| @32|║| +0#0000000#ffffff0@32
4+|║+0#0000001#ffd7ff255|l+0#af5f00255&|e| +0#0000001#e0e0e08|o|n|l|y| @10| +0&#ffd7ff255@21|║| +0#0000000#ffffff0@32
5+|║+0#0000001#ffd7ff255|e+0#af5f00255&|c| +0#0000001&|o|f@1| @33|║| +0#0000000#ffffff0@32
6+|║+0#0000001#ffd7ff255|e+0#af5f00255&|c| +0#0000001&|o|n|e| @33|║| +0#0000000#ffffff0@32
7+|║+0#0000001#ffd7ff255|c+0#af5f00255&|a|l@1| +0#0000001&|s+0#00e0e07&|y|s|t|e|m|(+0#e000e06&|'+0#e000002&|e|c|h|o| |h|e|l@1|o|'|)+0#e000e06&| +0#0000001&@14|║| +0#0000000#ffffff0@32
8+|║+0#0000001#ffd7ff255|"+0#0000e05&| |t|h|e| |e|n|d| +0#0000001&@30|║| +0#4040ff13#ffffff0@32
9+|╚+0#0000001#ffd7ff255|═@39|⇲| +0#4040ff13#ffffff0@32
10+|~| @73
11+|~| @73
12+|-+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| |3| |o|f| |5| +0#0000000&@33
diff -r 157961d500ff -r c5356021a938 src/testdir/dumps/Test_pum_preview_4.dump
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/testdir/dumps/Test_pum_preview_4.dump Sun Oct 02 15:30:07 2022 +0200
@@ -0,0 +1,12 @@
1+|o+0&#ffffff0|n|e| |o|f@1> @67
2+|╔+0#0000001#ffd7ff255| |X| |o|t|h|e|r| @9|═@21|X| +0#0000000#ffffff0@32
3+|║+0#0000001#ffd7ff255|l+0#af5f00255&|e| +0#0000001&|o|n|c|e| @32|║| +0#0000000#ffffff0@32
4+|║+0#0000001#ffd7ff255|l+0#af5f00255&|e| +0#0000001&|o|n|l|y| @32|║| +0#0000000#ffffff0@32
5+|║+0#0000001#ffd7ff255|e+0#af5f00255&|c| +0#0000001#e0e0e08|o|f@1| @11| +0&#ffd7ff255@21|║| +0#0000000#ffffff0@32
6+|║+0#0000001#ffd7ff255|e+0#af5f00255&|c| +0#0000001&|o|n|e| @33|║| +0#0000000#ffffff0@32
7+|║+0#0000001#ffd7ff255|c+0#af5f00255&|a|l@1| +0#0000001&|s+0#00e0e07&|y|s|t|e|m|(+0#e000e06&|'+0#e000002&|e|c|h|o| |h|e|l@1|o|'|)+0#e000e06&| +0#0000001&@14|║| +0#0000000#ffffff0@32
8+|║+0#0000001#ffd7ff255|"+0#0000e05&| |t|h|e| |e|n|d| +0#0000001&@30|║| +0#4040ff13#ffffff0@32
9+|╚+0#0000001#ffd7ff255|═@39|⇲| +0#4040ff13#ffffff0@32
10+|~| @73
11+|~| @73
12+|-+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| |4| |o|f| |5| +0#0000000&@33
diff -r 157961d500ff -r c5356021a938 src/testdir/test_popupwin.vim
--- a/src/testdir/test_popupwin.vim Sun Oct 02 14:00:10 2022 +0200
+++ b/src/testdir/test_popupwin.vim Sun Oct 02 15:30:07 2022 +0200
@@ -3362,6 +3362,45 @@
33623362 call StopVimInTerminal(buf)
33633363 endfunc
33643364
3365+func Test_previewpopup_pum()
3366+ CheckScreendump
3367+ CheckFeature quickfix
3368+
3369+ let lines =<< trim END
3370+ let a = 3
3371+ let b = 1
3372+ echo a
3373+ echo b
3374+ call system('echo hello')
3375+ " the end
3376+ END
3377+ call writefile(lines, 'XpreviewText.vim', 'D')
3378+
3379+ let lines =<< trim END
3380+ call setline(1, ['one', 'two', 'three', 'other', 'once', 'only', 'off'])
3381+ set previewpopup=height:6,width:40
3382+ pedit XpreviewText.vim
3383+ END
3384+ call writefile(lines, 'XtestPreviewPum', 'D')
3385+ let buf = RunVimInTerminal('-S XtestPreviewPum', #{rows: 12})
3386+
3387+ call term_sendkeys(buf, "A o\<C-N>")
3388+ call VerifyScreenDump(buf, 'Test_pum_preview_1', {})
3389+
3390+ call term_sendkeys(buf, "\<C-N>")
3391+ call VerifyScreenDump(buf, 'Test_pum_preview_2', {})
3392+
3393+ call term_sendkeys(buf, "\<C-N>")
3394+ call VerifyScreenDump(buf, 'Test_pum_preview_3', {})
3395+
3396+ call term_sendkeys(buf, "\<C-N>")
3397+ call VerifyScreenDump(buf, 'Test_pum_preview_4', {})
3398+
3399+ call term_sendkeys(buf, "\<Esc>")
3400+ call StopVimInTerminal(buf)
3401+endfunc
3402+
3403+
33653404 func Get_popupmenu_lines()
33663405 let lines =<< trim END
33673406 set completeopt+=preview,popup
diff -r 157961d500ff -r c5356021a938 src/version.c
--- a/src/version.c Sun Oct 02 14:00:10 2022 +0200
+++ b/src/version.c Sun Oct 02 15:30:07 2022 +0200
@@ -700,6 +700,8 @@
700700 static int included_patches[] =
701701 { /* Add new patch number below this line */
702702 /**/
703+ 638,
704+/**/
703705 637,
704706 /**/
705707 636,
Show on old repository browser