vim-patch:8.2.4929: off-by-one error in in statusline item

Problem:    Off-by-one error in in statusline item.
Solution:   Subtrace one less. (closes vim/vim#10394, closes vim/vim#5599)
57ff52677b
This commit is contained in:
zeertzjq 2022-05-10 07:38:44 +08:00
parent 9aa5647e68
commit 406c2e35b3
2 changed files with 20 additions and 2 deletions

View File

@ -3635,7 +3635,8 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, int use_san
// correct the start of the items for the truncation
for (int idx = stl_groupitems[groupdepth] + 1; idx < curitem; idx++) {
// Shift everything back by the number of removed bytes
stl_items[idx].start -= n;
// Minus one for the leading '<' added above.
stl_items[idx].start -= n - 1;
// If the item was partially or completely truncated, set its
// start to the start of the group

View File

@ -461,7 +461,6 @@ func Test_statusline_removed_group()
call writefile(lines, 'XTest_statusline')
let buf = RunVimInTerminal('-S XTest_statusline', {'rows': 10, 'cols': 50})
call term_wait(buf, 100)
call VerifyScreenDump(buf, 'Test_statusline_1', {})
" clean up
@ -535,4 +534,22 @@ func Test_statusline_verylong_filename()
bwipe!
endfunc
func Test_statusline_highlight_truncate()
CheckScreendump
let lines =<< trim END
set laststatus=2
hi! link User1 Directory
hi! link User2 ErrorMsg
set statusline=%.5(%1*ABC%2*DEF%1*GHI%)
END
call writefile(lines, 'XTest_statusline')
let buf = RunVimInTerminal('-S XTest_statusline', {'rows': 6})
call VerifyScreenDump(buf, 'Test_statusline_hl', {})
call StopVimInTerminal(buf)
call delete('XTest_statusline')
endfunc
" vim: shiftwidth=2 sts=2 expandtab