From 2252d2c1e5fe0250923adf52dc7a3e874e8f6690 Mon Sep 17 00:00:00 2001 From: Foxe Chen Date: Wed, 15 Apr 2026 16:52:09 +0000 Subject: [PATCH] patch 9.2.0352: 'winhighlight' of left window blends into right window Problem: 'winhighlight' of left window blends into right window Solution: Allow to push a NULL highlight override (Foxe Chen) closes: #19980 Signed-off-by: Foxe Chen Signed-off-by: Christian Brabandt --- src/highlight.c | 13 +++++++---- src/testdir/dumps/Test_VertSplitNC_whl1.dump | 12 ++++++++++ src/testdir/dumps/Test_VertSplitNC_whl2.dump | 12 ++++++++++ src/testdir/test_highlight.vim | 24 ++++++++++++++++++++ src/version.c | 2 ++ 5 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 src/testdir/dumps/Test_VertSplitNC_whl1.dump create mode 100644 src/testdir/dumps/Test_VertSplitNC_whl2.dump diff --git a/src/highlight.c b/src/highlight.c index 8baa44afe1..eb7707c81f 100644 --- a/src/highlight.c +++ b/src/highlight.c @@ -184,7 +184,8 @@ typedef struct typedef struct hl_overrides_S hl_overrides_T; struct hl_overrides_S { - hl_override_T *arr; // May be NULL if "arr" was freed + hl_override_T *arr; // May be NULL if "arr" was freed or no highlight + // overrides (all values set to default) int len; hl_overrides_T *next; // Used to handle recursive calls @@ -5804,9 +5805,10 @@ set_highlight_attr(hl_override_T *arr, int len, bool update_ids) bool push_highlight_overrides(hl_override_T *arr, int len) { - // Don't want to do anything if "arr" is NULL or if "arr" is already the - // current override. - if (arr == NULL || (overrides != NULL && overrides->arr == arr)) + // Don't want to do anything if "arr" is already the current override. If + // "arr" is NULL (but overrides->arr is not), then still push an override, + // but "->arr" will just be NULL so any previous overrides are cleared. + if (overrides != NULL && overrides->arr == arr) return false; hl_overrides_T *set; @@ -5831,7 +5833,8 @@ push_highlight_overrides(hl_override_T *arr, int len) memcpy(highlight_attr, highlight_attr_raw, sizeof(highlight_attr)); // Update highlight_attr[] array - set_highlight_attr(arr, len, false); + if (arr != NULL) + set_highlight_attr(arr, len, false); return true; } diff --git a/src/testdir/dumps/Test_VertSplitNC_whl1.dump b/src/testdir/dumps/Test_VertSplitNC_whl1.dump new file mode 100644 index 0000000000..b6267ef1ae --- /dev/null +++ b/src/testdir/dumps/Test_VertSplitNC_whl1.dump @@ -0,0 +1,12 @@ +> +0&#ffffff0@36||+1&&| +0&&@36 +|~+0#4040ff13&| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|[+0#ffffff16#e000002|N|o| |N|a|m|e|]| @9|0|,|0|-|1| @9|A|l@1| |[+1#0000000#ffffff0|N|o| |N|a|m|e|]| @9|0|,|0|-|1| @9|A|l@1 +| +0&&@74 diff --git a/src/testdir/dumps/Test_VertSplitNC_whl2.dump b/src/testdir/dumps/Test_VertSplitNC_whl2.dump new file mode 100644 index 0000000000..825775e591 --- /dev/null +++ b/src/testdir/dumps/Test_VertSplitNC_whl2.dump @@ -0,0 +1,12 @@ +| +0&#ffffff0@36||+1&&> +0&&@36 +|~+0#4040ff13&| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|[+1#0000000&|N|o| |N|a|m|e|]| @9|0|,|0|-|1| @9|A|l@1| +3&&|[|N|o| |N|a|m|e|]| @9|0|,|0|-|1| @9|A|l@1 +| +0&&@74 diff --git a/src/testdir/test_highlight.vim b/src/testdir/test_highlight.vim index 584693f807..6968e72b6a 100644 --- a/src/testdir/test_highlight.vim +++ b/src/testdir/test_highlight.vim @@ -1788,4 +1788,28 @@ func Test_VertSplitNC_fillchars() call StopVimInTerminal(buf) endfunc +" Test that 'winhighlight' of window left of separator does not apply when +" drawing the window to the right of the separator. +func Test_VertSplitNC_winhighlight() + CheckScreendump + + let lines =<< trim END + vsplit + set winhighlight=StatusLine:ErrorMsg + END + call writefile(lines, 'Xtest_vertsplitNC_winhighlight', 'D') + + let buf = RunVimInTerminal('-S Xtest_vertsplitNC_winhighlight', {'rows': 12}) + call TermWait(buf) + + call VerifyScreenDump(buf, 'Test_VertSplitNC_whl1', {}) + + call term_sendkeys(buf, "\\") " Go to window with empty winhighlight + call TermWait(buf) + + call VerifyScreenDump(buf, 'Test_VertSplitNC_whl2', {}) + + call StopVimInTerminal(buf) +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index 3c64afaa92..2eb306c56b 100644 --- a/src/version.c +++ b/src/version.c @@ -734,6 +734,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 352, /**/ 351, /**/