summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-10-02 14:28:30 +0100
committerBram Moolenaar <Bram@vim.org>2022-10-02 14:28:30 +0100
commit393f8d61f55cb6127a100e812ba4d66097a32d2e (patch)
tree979245f3f96e888e53c6db6b09a8a0f7c68ea749
parenteda29c971c0592d85c5856da7708f3edfdc54cfa (diff)
downloadvim-git-393f8d61f55cb6127a100e812ba4d66097a32d2e.tar.gz
patch 9.0.0638: popup menu highlight wrong on top of preview popupv9.0.0638
Problem: Popup menu highlight wrong on top of preview popup. (Yegappan Lakshmanan) Solution: Also check for the popup menu in screen_line().
-rw-r--r--src/screen.c42
-rw-r--r--src/testdir/dumps/Test_pum_preview_1.dump12
-rw-r--r--src/testdir/dumps/Test_pum_preview_2.dump12
-rw-r--r--src/testdir/dumps/Test_pum_preview_3.dump12
-rw-r--r--src/testdir/dumps/Test_pum_preview_4.dump12
-rw-r--r--src/testdir/test_popupwin.vim39
-rw-r--r--src/version.c2
7 files changed, 114 insertions, 17 deletions
diff --git a/src/screen.c b/src/screen.c
index f5dfa0590..ffea59372 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -420,6 +420,27 @@ reset_screen_attr(void)
}
/*
+ * Return TRUE if the character at "row" / "col" is under the popup menu and it
+ * will be redrawn soon or it is under another popup.
+ */
+ static int
+skip_for_popup(int row, int col)
+{
+ // Popup windows with zindex higher than POPUPMENU_ZINDEX go on top.
+ if (pum_under_menu(row, col, TRUE)
+#ifdef FEAT_PROP_POPUP
+ && screen_zindex <= POPUPMENU_ZINDEX
+#endif
+ )
+ return TRUE;
+#ifdef FEAT_PROP_POPUP
+ if (blocked_by_popup(row, col))
+ return TRUE;
+#endif
+ return FALSE;
+}
+
+/*
* Move one "cooked" screen line to the screen, but only the characters that
* have actually changed. Handle insert/delete character.
* "coloff" gives the first column on the screen for this line.
@@ -538,10 +559,10 @@ screen_line(
redraw_this = TRUE;
}
#endif
-#ifdef FEAT_PROP_POPUP
- if (blocked_by_popup(row, col + coloff))
+ // Do not redraw if under the popup menu.
+ if (redraw_this && skip_for_popup(row, col + coloff))
redraw_this = FALSE;
-#endif
+
if (redraw_this)
{
/*
@@ -669,15 +690,11 @@ screen_line(
}
#endif
ScreenAttrs[off_to] = ScreenAttrs[off_from];
- ScreenCols[off_to] = ScreenCols[off_from];
// For simplicity set the attributes of second half of a
// double-wide character equal to the first half.
if (char_cells == 2)
- {
ScreenAttrs[off_to + 1] = ScreenAttrs[off_from];
- ScreenCols[off_to + 1] = ScreenCols[off_from + 1];
- }
if (enc_dbcs != 0 && char_cells == 2)
screen_char_2(off_to, row, col + coloff);
@@ -2165,17 +2182,8 @@ screen_char(unsigned off, int row, int col)
return;
// Skip if under the popup menu.
- // Popup windows with zindex higher than POPUPMENU_ZINDEX go on top.
- if (pum_under_menu(row, col, TRUE)
-#ifdef FEAT_PROP_POPUP
- && screen_zindex <= POPUPMENU_ZINDEX
-#endif
- )
+ if (skip_for_popup(row, col))
return;
-#ifdef FEAT_PROP_POPUP
- if (blocked_by_popup(row, col))
- return;
-#endif
// Outputting a character in the last cell on the screen may scroll the
// screen up. Only do it when the "xn" termcap property is set, otherwise
diff --git a/src/testdir/dumps/Test_pum_preview_1.dump b/src/testdir/dumps/Test_pum_preview_1.dump
new file mode 100644
index 000000000..e8f42254c
--- /dev/null
+++ b/src/testdir/dumps/Test_pum_preview_1.dump
@@ -0,0 +1,12 @@
+|o+0&#ffffff0|n|e| |o|t|h|e|r> @65
+|╔+0#0000001#ffd7ff255| |X| +0&#e0e0e08|o|t|h|e|r| @9|═+0&#ffd7ff255@21|X| +0#0000000#ffffff0@32
+|║+0#0000001#ffd7ff255|l+0#af5f00255&|e| +0#0000001&|o|n|c|e| @32|║| +0#0000000#ffffff0@32
+|║+0#0000001#ffd7ff255|l+0#af5f00255&|e| +0#0000001&|o|n|l|y| @32|║| +0#0000000#ffffff0@32
+|║+0#0000001#ffd7ff255|e+0#af5f00255&|c| +0#0000001&|o|f@1| @33|║| +0#0000000#ffffff0@32
+|║+0#0000001#ffd7ff255|e+0#af5f00255&|c| +0#0000001&|o|n|e| @33|║| +0#0000000#ffffff0@32
+|║+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
+|║+0#0000001#ffd7ff255|"+0#0000e05&| |t|h|e| |e|n|d| +0#0000001&@30|║| +0#4040ff13#ffffff0@32
+|╚+0#0000001#ffd7ff255|═@39|⇲| +0#4040ff13#ffffff0@32
+|~| @73
+|~| @73
+|-+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 --git a/src/testdir/dumps/Test_pum_preview_2.dump b/src/testdir/dumps/Test_pum_preview_2.dump
new file mode 100644
index 000000000..a9fcfc9be
--- /dev/null
+++ b/src/testdir/dumps/Test_pum_preview_2.dump
@@ -0,0 +1,12 @@
+|o+0&#ffffff0|n|e| |o|n|c|e> @66
+|╔+0#0000001#ffd7ff255| |X| |o|t|h|e|r| @9|═@21|X| +0#0000000#ffffff0@32
+|║+0#0000001#ffd7ff255|l+0#af5f00255&|e| +0#0000001#e0e0e08|o|n|c|e| @10| +0&#ffd7ff255@21|║| +0#0000000#ffffff0@32
+|║+0#0000001#ffd7ff255|l+0#af5f00255&|e| +0#0000001&|o|n|l|y| @32|║| +0#0000000#ffffff0@32
+|║+0#0000001#ffd7ff255|e+0#af5f00255&|c| +0#0000001&|o|f@1| @33|║| +0#0000000#ffffff0@32
+|║+0#0000001#ffd7ff255|e+0#af5f00255&|c| +0#0000001&|o|n|e| @33|║| +0#0000000#ffffff0@32
+|║+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
+|║+0#0000001#ffd7ff255|"+0#0000e05&| |t|h|e| |e|n|d| +0#0000001&@30|║| +0#4040ff13#ffffff0@32
+|╚+0#0000001#ffd7ff255|═@39|⇲| +0#4040ff13#ffffff0@32
+|~| @73
+|~| @73
+|-+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 --git a/src/testdir/dumps/Test_pum_preview_3.dump b/src/testdir/dumps/Test_pum_preview_3.dump
new file mode 100644
index 000000000..6b14ce313
--- /dev/null
+++ b/src/testdir/dumps/Test_pum_preview_3.dump
@@ -0,0 +1,12 @@
+|o+0&#ffffff0|n|e| |o|n|l|y> @66
+|╔+0#0000001#ffd7ff255| |X| |o|t|h|e|r| @9|═@21|X| +0#0000000#ffffff0@32
+|║+0#0000001#ffd7ff255|l+0#af5f00255&|e| +0#0000001&|o|n|c|e| @32|║| +0#0000000#ffffff0@32
+|║+0#0000001#ffd7ff255|l+0#af5f00255&|e| +0#0000001#e0e0e08|o|n|l|y| @10| +0&#ffd7ff255@21|║| +0#0000000#ffffff0@32
+|║+0#0000001#ffd7ff255|e+0#af5f00255&|c| +0#0000001&|o|f@1| @33|║| +0#0000000#ffffff0@32
+|║+0#0000001#ffd7ff255|e+0#af5f00255&|c| +0#0000001&|o|n|e| @33|║| +0#0000000#ffffff0@32
+|║+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
+|║+0#0000001#ffd7ff255|"+0#0000e05&| |t|h|e| |e|n|d| +0#0000001&@30|║| +0#4040ff13#ffffff0@32
+|╚+0#0000001#ffd7ff255|═@39|⇲| +0#4040ff13#ffffff0@32
+|~| @73
+|~| @73
+|-+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 --git a/src/testdir/dumps/Test_pum_preview_4.dump b/src/testdir/dumps/Test_pum_preview_4.dump
new file mode 100644
index 000000000..40254a844
--- /dev/null
+++ b/src/testdir/dumps/Test_pum_preview_4.dump
@@ -0,0 +1,12 @@
+|o+0&#ffffff0|n|e| |o|f@1> @67
+|╔+0#0000001#ffd7ff255| |X| |o|t|h|e|r| @9|═@21|X| +0#0000000#ffffff0@32
+|║+0#0000001#ffd7ff255|l+0#af5f00255&|e| +0#0000001&|o|n|c|e| @32|║| +0#0000000#ffffff0@32
+|║+0#0000001#ffd7ff255|l+0#af5f00255&|e| +0#0000001&|o|n|l|y| @32|║| +0#0000000#ffffff0@32
+|║+0#0000001#ffd7ff255|e+0#af5f00255&|c| +0#0000001#e0e0e08|o|f@1| @11| +0&#ffd7ff255@21|║| +0#0000000#ffffff0@32
+|║+0#0000001#ffd7ff255|e+0#af5f00255&|c| +0#0000001&|o|n|e| @33|║| +0#0000000#ffffff0@32
+|║+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
+|║+0#0000001#ffd7ff255|"+0#0000e05&| |t|h|e| |e|n|d| +0#0000001&@30|║| +0#4040ff13#ffffff0@32
+|╚+0#0000001#ffd7ff255|═@39|⇲| +0#4040ff13#ffffff0@32
+|~| @73
+|~| @73
+|-+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 --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim
index 0e2eec0aa..29b7b7df9 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -3362,6 +3362,45 @@ func Test_previewpopup()
call StopVimInTerminal(buf)
endfunc
+func Test_previewpopup_pum()
+ CheckScreendump
+ CheckFeature quickfix
+
+ let lines =<< trim END
+ let a = 3
+ let b = 1
+ echo a
+ echo b
+ call system('echo hello')
+ " the end
+ END
+ call writefile(lines, 'XpreviewText.vim', 'D')
+
+ let lines =<< trim END
+ call setline(1, ['one', 'two', 'three', 'other', 'once', 'only', 'off'])
+ set previewpopup=height:6,width:40
+ pedit XpreviewText.vim
+ END
+ call writefile(lines, 'XtestPreviewPum', 'D')
+ let buf = RunVimInTerminal('-S XtestPreviewPum', #{rows: 12})
+
+ call term_sendkeys(buf, "A o\<C-N>")
+ call VerifyScreenDump(buf, 'Test_pum_preview_1', {})
+
+ call term_sendkeys(buf, "\<C-N>")
+ call VerifyScreenDump(buf, 'Test_pum_preview_2', {})
+
+ call term_sendkeys(buf, "\<C-N>")
+ call VerifyScreenDump(buf, 'Test_pum_preview_3', {})
+
+ call term_sendkeys(buf, "\<C-N>")
+ call VerifyScreenDump(buf, 'Test_pum_preview_4', {})
+
+ call term_sendkeys(buf, "\<Esc>")
+ call StopVimInTerminal(buf)
+endfunc
+
+
func Get_popupmenu_lines()
let lines =<< trim END
set completeopt+=preview,popup
diff --git a/src/version.c b/src/version.c
index 7c8be051e..dd80828a0 100644
--- a/src/version.c
+++ b/src/version.c
@@ -700,6 +700,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 638,
+/**/
637,
/**/
636,