patch 9.2.0352: 'winhighlight' of left window blends into right window

Commit: 
https://github.com/vim/vim/commit/2252d2c1e5fe0250923adf52dc7a3e874e8f6690
Author: Foxe Chen <[email protected]>
Date:   Wed Apr 15 16:52:09 2026 +0000

    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 <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/highlight.c b/src/highlight.c
index 8baa44afe..eb7707c81 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 000000000..b6267ef1a
--- /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 000000000..825775e59
--- /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 584693f80..6968e72b6 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, "\<C-w>\<C-l>") " 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 3c64afaa9..2eb306c56 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,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1wD3at-004JxZ-Vl%40256bit.org.

Raspunde prin e-mail lui