]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1378: sign without text overwrites number option v9.1.1378
authorglepnir <glephunter@gmail.com>
Sat, 10 May 2025 12:59:08 +0000 (14:59 +0200)
committerChristian Brabandt <cb@256bit.org>
Sat, 10 May 2025 12:59:08 +0000 (14:59 +0200)
Problem:  When 'signcolumn' is set to `number` but a line has a sign
          without text, the line number disappears (finite-state-machine)
Solution: Verify that a sign actually contains text before rendering the
          line number (glepnir)

fixes: #17169
closes: #17282

Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/drawline.c
src/testdir/dumps/Test_sign_number_without_signtext.dump [new file with mode: 0644]
src/testdir/test_signs.vim
src/version.c

index a14dd906225fbd6dd2f3586c2a909df6cc34c4c0..57ee9a5fda0d8061cc475489514085794f01ec67 100644 (file)
@@ -388,7 +388,8 @@ handle_lnum_col(
        // If 'signcolumn' is set to 'number' and a sign is present
        // in 'lnum', then display the sign instead of the line
        // number.
-       if ((*wp->w_p_scl == 'n' && *(wp->w_p_scl + 1) == 'u') && sign_present)
+       if ((*wp->w_p_scl == 'n' && *(wp->w_p_scl + 1) == 'u') && sign_present
+               && wlv->sattr.sat_text != NULL)
            get_sign_display_info(TRUE, wp, wlv);
        else
 #endif
diff --git a/src/testdir/dumps/Test_sign_number_without_signtext.dump b/src/testdir/dumps/Test_sign_number_without_signtext.dump
new file mode 100644 (file)
index 0000000..0cf55bd
--- /dev/null
@@ -0,0 +1,5 @@
+| +0#ffffff16#ff404010|>@1| >a+0#0000000#ffffff0| @69
+| +0#ffffff16#ff404010@1|2| |b+0#0000000#ffffff0| @69
+| +0#af5f00255&@1|3| |c+0#0000000&| @69
+|~+0#4040ff13&| @73
+| +0#0000000&@56|1|,|1| @10|A|l@1| 
index 8304298f6dca1a612e37f0692f5b3497b0289a4f..e66e6fa0115e85dedca7f506e88c2905cb9e4bde 100644 (file)
@@ -2103,4 +2103,23 @@ func Test_sign_null_list()
   eval test_null_list()->sign_unplacelist()
 endfunc
 
+func Test_sign_number_without_signtext()
+  CheckScreendump
+  CheckRunVimInTerminal
+
+  let lines =<< trim END
+      set number signcolumn=number
+      call setline(1, ['a', 'b', 'c'])
+      sign define SignA text=>> texthl=Search numhl=Error
+      sign define SignB numhl=Error
+      sign place 1 line=1 name=SignA buffer=1
+      sign place 2 line=2 name=SignB  buffer=1
+  END
+  call writefile(lines, 'XtestSigncolumnNumber', 'D')
+  let buf = RunVimInTerminal('-S XtestSigncolumnNumber', {'rows': 5})
+  call VerifyScreenDump(buf, 'Test_sign_number_without_signtext', {})
+
+  call StopVimInTerminal(buf)
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index aa7f461803e302a3ff10f7a87ef6e77979ac9ff9..c84709e5007ab05db4ec3997640bde42ea43c030 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1378,
 /**/
     1377,
 /**/