patch 9.1.1378: sign without text overwrites number option

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>
This commit is contained in:
glepnir
2025-05-10 14:59:08 +02:00
committed by Christian Brabandt
parent 0553f2ff0d
commit 1b186833c1
4 changed files with 28 additions and 1 deletions

View 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

View File

@ -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|

View 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

View File

@ -704,6 +704,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1378,
/**/
1377,
/**/