]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0352: 'winhighlight' of left window blends into right window v9.2.0352
authorFoxe Chen <chen.foxe@gmail.com>
Wed, 15 Apr 2026 16:52:09 +0000 (16:52 +0000)
committerChristian Brabandt <cb@256bit.org>
Wed, 15 Apr 2026 16:52:09 +0000 (16:52 +0000)
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 <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/highlight.c
src/testdir/dumps/Test_VertSplitNC_whl1.dump [new file with mode: 0644]
src/testdir/dumps/Test_VertSplitNC_whl2.dump [new file with mode: 0644]
src/testdir/test_highlight.vim
src/version.c

index 8baa44afe17af110737dd9ff3e299055397af396..eb7707c81f0fe9eae3a4dcd9d2fd6add9e72849f 100644 (file)
@@ -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 (file)
index 0000000..b6267ef
--- /dev/null
@@ -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 (file)
index 0000000..825775e
--- /dev/null
@@ -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
index 584693f80729be0210b5881c2abaef1b11c3397c..6968e72b6a11d91580c853544aac9777d57b7cf1 100644 (file)
@@ -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
index 3c64afaa9276cc14ccfcccb7239f83b56644d46b..2eb306c56beeb06c0bec7c16c00e73f203557f20 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    352,
 /**/
     351,
 /**/