Merge pull request #29357 from luukvbaal/statuscol

feat(column)!: rework 'statuscolumn' %r/l items
This commit is contained in:
zeertzjq
2024-06-17 06:33:15 +08:00
committed by GitHub
10 changed files with 268 additions and 226 deletions

View File

@@ -62,7 +62,10 @@ LUA
OPTIONS OPTIONS
• TODO • The 'statuscolumn' `%l` item can now be used as a number column segment that
changes according to related options. It takes care of alignment, 'number',
'relativenumber' and 'signcolumn' set to "number". The now redundant `%r` item
is no longer treated specially for 'statuscolumn'.
PLUGINS PLUGINS

View File

@@ -5954,8 +5954,7 @@ A jump table for the options with a short description can be found at |Q_op|.
Some of the items from the 'statusline' format are different for Some of the items from the 'statusline' format are different for
'statuscolumn': 'statuscolumn':
%l line number of currently drawn line %l line number column for currently drawn line
%r relative line number of currently drawn line
%s sign column for currently drawn line %s sign column for currently drawn line
%C fold column for currently drawn line %C fold column for currently drawn line
@@ -5982,11 +5981,8 @@ A jump table for the options with a short description can be found at |Q_op|.
handler should be written with this in mind. handler should be written with this in mind.
Examples: >vim Examples: >vim
" Relative number with bar separator and click handlers: " Line number with bar separator and click handlers:
set statuscolumn=%@SignCb@%s%=%T%@NumCb@%r│%T set statuscolumn=%@SignCb@%s%=%T%@NumCb@%l│%T
" Right aligned relative cursor line number:
let &stc='%=%{v:relnum?v:relnum:v:lnum} '
" Line numbers in hexadecimal for non wrapped part of lines: " Line numbers in hexadecimal for non wrapped part of lines:
let &stc='%=%{v:virtnum>0?"":printf("%x",v:lnum)} ' let &stc='%=%{v:virtnum>0?"":printf("%x",v:lnum)} '

View File

@@ -6376,8 +6376,7 @@ vim.go.sol = vim.go.startofline
--- Some of the items from the 'statusline' format are different for --- Some of the items from the 'statusline' format are different for
--- 'statuscolumn': --- 'statuscolumn':
--- ---
--- %l line number of currently drawn line --- %l line number column for currently drawn line
--- %r relative line number of currently drawn line
--- %s sign column for currently drawn line --- %s sign column for currently drawn line
--- %C fold column for currently drawn line --- %C fold column for currently drawn line
--- ---
@@ -6406,11 +6405,8 @@ vim.go.sol = vim.go.startofline
--- Examples: --- Examples:
--- ---
--- ```vim --- ```vim
--- " Relative number with bar separator and click handlers: --- " Line number with bar separator and click handlers:
--- set statuscolumn=%@SignCb@%s%=%T%@NumCb@%r│%T --- set statuscolumn=%@SignCb@%s%=%T%@NumCb@%l│%T
---
--- " Right aligned relative cursor line number:
--- let &stc='%=%{v:relnum?v:relnum:v:lnum} '
--- ---
--- " Line numbers in hexadecimal for non wrapped part of lines: --- " Line numbers in hexadecimal for non wrapped part of lines:
--- let &stc='%=%{v:virtnum>0?"":printf("%x",v:lnum)} ' --- let &stc='%=%{v:virtnum>0?"":printf("%x",v:lnum)} '

View File

@@ -587,12 +587,13 @@ static void draw_statuscol(win_T *wp, winlinevars_T *wlv, linenr_T lnum, int vir
char buf[MAXPATHL]; char buf[MAXPATHL];
// When a buffer's line count has changed, make a best estimate for the full // When a buffer's line count has changed, make a best estimate for the full
// width of the status column by building with "w_nrwidth_line_count". Add // width of the status column by building with the largest possible line number.
// potentially truncated width and rebuild before drawing anything. // Add potentially truncated width and rebuild before drawing anything.
if (wp->w_statuscol_line_count != wp->w_nrwidth_line_count) { if (wp->w_statuscol_line_count != wp->w_nrwidth_line_count) {
wp->w_statuscol_line_count = wp->w_nrwidth_line_count; wp->w_statuscol_line_count = wp->w_nrwidth_line_count;
set_vim_var_nr(VV_VIRTNUM, 0); set_vim_var_nr(VV_VIRTNUM, 0);
int width = build_statuscol_str(wp, wp->w_nrwidth_line_count, 0, buf, stcp); int width = build_statuscol_str(wp, wp->w_nrwidth_line_count,
wp->w_nrwidth_line_count, buf, stcp);
if (width > stcp->width) { if (width > stcp->width) {
int addwidth = MIN(width - stcp->width, MAX_STCWIDTH - stcp->width); int addwidth = MIN(width - stcp->width, MAX_STCWIDTH - stcp->width);
wp->w_nrwidth += addwidth; wp->w_nrwidth += addwidth;

View File

@@ -8040,8 +8040,7 @@ return {
Some of the items from the 'statusline' format are different for Some of the items from the 'statusline' format are different for
'statuscolumn': 'statuscolumn':
%l line number of currently drawn line %l line number column for currently drawn line
%r relative line number of currently drawn line
%s sign column for currently drawn line %s sign column for currently drawn line
%C fold column for currently drawn line %C fold column for currently drawn line
@@ -8068,11 +8067,8 @@ return {
handler should be written with this in mind. handler should be written with this in mind.
Examples: >vim Examples: >vim
" Relative number with bar separator and click handlers: " Line number with bar separator and click handlers:
set statuscolumn=%@SignCb@%s%=%T%@NumCb@%r│%T set statuscolumn=%@SignCb@%s%=%T%@NumCb@%l│%T
" Right aligned relative cursor line number:
let &stc='%=%{v:relnum?v:relnum:v:lnum} '
" Line numbers in hexadecimal for non wrapped part of lines: " Line numbers in hexadecimal for non wrapped part of lines:
let &stc='%=%{v:virtnum>0?"":printf("%x",v:lnum)} ' let &stc='%=%{v:virtnum>0?"":printf("%x",v:lnum)} '

View File

@@ -1017,7 +1017,6 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, OptIndex op
int evaldepth = 0; int evaldepth = 0;
int curitem = 0; int curitem = 0;
int foldsignitem = -1;
bool prevchar_isflag = true; bool prevchar_isflag = true;
bool prevchar_isitem = false; bool prevchar_isitem = false;
@@ -1234,6 +1233,8 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, OptIndex op
} }
int minwid = 0; int minwid = 0;
int maxwid = 9999; int maxwid = 9999;
int foldsignitem = -1; // Start of fold or sign item
bool left_align_num = false; // Number item for should be left-aligned
bool left_align = false; bool left_align = false;
// Denotes that numbers should be left-padded with zeros // Denotes that numbers should be left-padded with zeros
@@ -1505,12 +1506,20 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, OptIndex op
} }
case STL_LINE: case STL_LINE:
// Overload %l with v:lnum for 'statuscolumn' // Overload %l with v:(re)lnum for 'statuscolumn'. Place a sign when 'signcolumn'
if (stcp != NULL) { // is set to "number". Take care of alignment for 'number' + 'relativenumber'.
if (wp->w_p_nu && !get_vim_var_nr(VV_VIRTNUM)) { if (stcp != NULL && (wp->w_p_nu || wp->w_p_rnu) && get_vim_var_nr(VV_VIRTNUM) == 0) {
num = (int)get_vim_var_nr(VV_LNUM); if (wp->w_maxscwidth == SCL_NUM && stcp->sattrs[0].text[0]) {
goto stcsign;
} }
} else { int relnum = (int)get_vim_var_nr(VV_RELNUM);
num = (!wp->w_p_rnu || (wp->w_p_nu && relnum == 0)) ? (int)get_vim_var_nr(VV_LNUM) : relnum;
left_align_num = wp->w_p_rnu && wp->w_p_nu && relnum == 0;
if (!left_align_num) {
stl_items[curitem].type = Separate;
stl_items[curitem++].start = out_p;
}
} else if (stcp == NULL) {
num = (wp->w_buffer->b_ml.ml_flags & ML_EMPTY) ? 0 : wp->w_cursor.lnum; num = (wp->w_buffer->b_ml.ml_flags & ML_EMPTY) ? 0 : wp->w_cursor.lnum;
} }
break; break;
@@ -1609,17 +1618,10 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, OptIndex op
case STL_ROFLAG: case STL_ROFLAG:
case STL_ROFLAG_ALT: case STL_ROFLAG_ALT:
// Overload %r with v:relnum for 'statuscolumn'
if (stcp != NULL) {
if (wp->w_p_rnu && !get_vim_var_nr(VV_VIRTNUM)) {
num = (int)get_vim_var_nr(VV_RELNUM);
}
} else {
itemisflag = true; itemisflag = true;
if (wp->w_buffer->b_p_ro) { if (wp->w_buffer->b_p_ro) {
str = (opt == STL_ROFLAG_ALT) ? ",RO" : _("[RO]"); str = (opt == STL_ROFLAG_ALT) ? ",RO" : _("[RO]");
} }
}
break; break;
case STL_HELPFLAG: case STL_HELPFLAG:
@@ -1632,21 +1634,20 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, OptIndex op
case STL_FOLDCOL: // 'C' for 'statuscolumn' case STL_FOLDCOL: // 'C' for 'statuscolumn'
case STL_SIGNCOL: { // 's' for 'statuscolumn' case STL_SIGNCOL: { // 's' for 'statuscolumn'
stcsign:
if (stcp == NULL) { if (stcp == NULL) {
break; break;
} }
bool fold = opt == STL_FOLDCOL; int fdc = opt == STL_FOLDCOL ? compute_foldcolumn(wp, 0) : 0;
int fdc = fold ? compute_foldcolumn(wp, 0) : 0; int width = opt == STL_FOLDCOL ? fdc > 0 : opt == STL_SIGNCOL ? wp->w_scwidth : 1;
int width = fold ? fdc > 0 : wp->w_scwidth;
if (width <= 0) { if (width <= 0) {
break; break;
} }
foldsignitem = curitem; foldsignitem = curitem;
char *p = NULL; if (fdc > 0) {
if (fold) { schar_T fold_buf[9];
schar_T fold_buf[10];
fill_foldcolumn(wp, stcp->foldinfo, (linenr_T)get_vim_var_nr(VV_LNUM), fill_foldcolumn(wp, stcp->foldinfo, (linenr_T)get_vim_var_nr(VV_LNUM),
0, fdc, NULL, fold_buf); 0, fdc, NULL, fold_buf);
stl_items[curitem].minwid = -((stcp->use_cul ? HLF_CLF : HLF_FC) + 1); stl_items[curitem].minwid = -((stcp->use_cul ? HLF_CLF : HLF_FC) + 1);
@@ -1654,31 +1655,26 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, OptIndex op
// TODO(bfredl): this is very backwards. we must support schar_T // TODO(bfredl): this is very backwards. we must support schar_T
// being used directly in 'statuscolumn' // being used directly in 'statuscolumn'
for (int i = 0; i < fdc; i++) { for (int i = 0; i < fdc; i++) {
buflen += schar_get(out_p + buflen, fold_buf[i]); buflen += schar_get(buf_tmp + buflen, fold_buf[i]);
} }
p = out_p;
} }
char buf[SIGN_WIDTH * MAX_SCHAR_SIZE]; size_t signlen = 0;
size_t buflen = 0;
varnumber_T virtnum = get_vim_var_nr(VV_VIRTNUM);
for (int i = 0; i < width; i++) { for (int i = 0; i < width; i++) {
if (!fold) { stl_items[curitem].start = out_p + signlen;
SignTextAttrs *sattr = virtnum ? NULL : &stcp->sattrs[i]; if (fdc == 0) {
p = " "; if (stcp->sattrs[i].text[0] && get_vim_var_nr(VV_VIRTNUM) == 0) {
if (sattr && sattr->text[0]) { SignTextAttrs sattrs = stcp->sattrs[i];
describe_sign_text(buf, sattr->text); signlen += describe_sign_text(buf_tmp + signlen, sattrs.text);
p = buf; stl_items[curitem].minwid = -(stcp->sign_cul_id ? stcp->sign_cul_id : sattrs.hl_id);
} else {
buf_tmp[signlen++] = ' ';
buf_tmp[signlen++] = ' ';
buf_tmp[signlen] = NUL;
stl_items[curitem].minwid = -((stcp->use_cul ? HLF_CLS : HLF_SC) + 1);
} }
stl_items[curitem].minwid = -(sattr && sattr->text[0]
? (stcp->sign_cul_id ? stcp->sign_cul_id : sattr->hl_id)
: (stcp->use_cul ? HLF_CLS : HLF_SC) + 1);
} }
stl_items[curitem].type = Highlight; stl_items[curitem++].type = Highlight;
stl_items[curitem].start = out_p + buflen;
xstrlcpy(buf_tmp + buflen, p, TMPLEN - buflen);
buflen += strlen(p);
curitem++;
} }
str = buf_tmp; str = buf_tmp;
break; break;
@@ -1851,7 +1847,6 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, OptIndex op
// For a 'statuscolumn' sign or fold item, add an item to reset the highlight group // For a 'statuscolumn' sign or fold item, add an item to reset the highlight group
if (foldsignitem >= 0) { if (foldsignitem >= 0) {
foldsignitem = -1;
stl_items[curitem].type = Highlight; stl_items[curitem].type = Highlight;
stl_items[curitem].start = out_p; stl_items[curitem].start = out_p;
stl_items[curitem].minwid = 0; stl_items[curitem].minwid = 0;
@@ -1956,6 +1951,11 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, OptIndex op
// Item processed, move to the next // Item processed, move to the next
curitem++; curitem++;
// For a 'statuscolumn' number item that is left aligned, add a separator item.
if (left_align_num) {
stl_items[curitem].type = Separate;
stl_items[curitem++].start = out_p;
}
} }
*out_p = NUL; *out_p = NUL;

View File

@@ -3888,10 +3888,10 @@ describe('API', function()
eq( eq(
{ {
str = ' 3 ', str = ' 3 ',
width = 2, width = 9,
highlights = { highlights = {
{ group = 'LineNr', start = 0 }, { group = 'LineNr', start = 0 },
{ group = 'ErrorMsg', start = 1 }, { group = 'ErrorMsg', start = 8 },
}, },
}, },
api.nvim_eval_statusline('%l%#ErrorMsg# ', { use_statuscol_lnum = 3, highlights = true }) api.nvim_eval_statusline('%l%#ErrorMsg# ', { use_statuscol_lnum = 3, highlights = true })

View File

@@ -1532,9 +1532,9 @@ describe('float window', function()
[2:----------------------------------------]|*6 [2:----------------------------------------]|*6
[3:----------------------------------------]| [3:----------------------------------------]|
## grid 2 ## grid 2
{20:1}{19: }{20: }{22:^x}{21: }| {20: 1}{19: }{22:^x}{21: }|
{14:2}{19: }{14: }{22:y} | {14: 2}{19: }{22:y} |
{14:3}{19: }{14: }{22: } | {14: 3}{19: }{22: } |
{0:~ }|*3 {0:~ }|*3
## grid 3 ## grid 3
| |
@@ -1545,9 +1545,9 @@ describe('float window', function()
]], float_pos={[4] = {1001, "NW", 1, 4, 10, true}}} ]], float_pos={[4] = {1001, "NW", 1, 4, 10, true}}}
else else
screen:expect{grid=[[ screen:expect{grid=[[
{20:1}{19: }{20: }{22:^x}{21: }| {20: 1}{19: }{22:^x}{21: }|
{14:2}{19: }{14: }{22:y} | {14: 2}{19: }{22:y} |
{14:3}{19: }{14: }{22: } {15:x } | {14: 3}{19: }{22: } {15:x } |
{0:~ }{15:y }{0: }| {0:~ }{15:y }{0: }|
{0:~ }{15: }{0: }|*2 {0:~ }{15: }{0: }|*2
| |

View File

@@ -94,46 +94,80 @@ describe('statuscolumn', function()
end) end)
it("works with 'number' and 'relativenumber'", function() it("works with 'number' and 'relativenumber'", function()
command([[set stc=%{&nu?v:lnum:''}%=%{&rnu?'\ '.v:relnum:''}│]])
screen:expect([[ screen:expect([[
{8:4 }aaaaa | {8: 4 }aaaaa |
{8:5 }aaaaa | {8: 5 }aaaaa |
{8:6 }aaaaa | {8: 6 }aaaaa |
{8:7 }aaaaa | {8: 7 }aaaaa |
{8:8 }^aaaaa | {8: 8 }^aaaaa |
{8:9 }aaaaa | {8: 9 }aaaaa |
{8:10}aaaaa | {8:10 }aaaaa |
{8:11}aaaaa | {8:11 }aaaaa |
{8:12}aaaaa | {8:12 }aaaaa |
{8:13}aaaaa | {8:13 }aaaaa |
{8:14}aaaaa | {8:14 }aaaaa |
{8:15}aaaaa | {8:15 }aaaaa |
{8:16}aaaaa | {8:16 }aaaaa |
| |
]]) ]])
command([[set stc=%l%=%{&rnu?'\ ':''}%r│]]) command([[set stc=%l\ ]])
screen:expect_unchanged() screen:expect_unchanged()
command([[set stc=%{&nu?v:lnum:''}%=%{&rnu?'\ '.v:relnum:''}│]])
command('set relativenumber') command('set relativenumber')
screen:expect([[ screen:expect([[
{8:4 4}aaaaa | {8: 4 }aaaaa |
{8:5 3}aaaaa | {8: 3 }aaaaa |
{8:6 2}aaaaa | {8: 2 }aaaaa |
{8:7 1}aaaaa | {8: 1 }aaaaa |
{8:8 0│}^aaaaa | {8:8 }^aaaaa |
{8:9 1}aaaaa | {8: 1 }aaaaa |
{8:10 2}aaaaa | {8: 2 }aaaaa |
{8:11 3}aaaaa | {8: 3 }aaaaa |
{8:12 4}aaaaa | {8: 4 }aaaaa |
{8:13 5}aaaaa | {8: 5 }aaaaa |
{8:14 6}aaaaa | {8: 6 }aaaaa |
{8:15 7}aaaaa | {8: 7 }aaaaa |
{8:16 8}aaaaa | {8: 8 }aaaaa |
| |
]]) ]])
command([[set stc=%l%=%{&rnu?'\ ':''}%r│]]) command('set stc=')
screen:expect_unchanged() screen:expect_unchanged()
command([[set stc=%{&nu?v:lnum:''}%=%{&rnu?'\ '.v:relnum:''}│]]) command([[set nonu stc=%l\ ]])
screen:expect([[
{8: 4 }aaaaa |
{8: 3 }aaaaa |
{8: 2 }aaaaa |
{8: 1 }aaaaa |
{8: 0 }^aaaaa |
{8: 1 }aaaaa |
{8: 2 }aaaaa |
{8: 3 }aaaaa |
{8: 4 }aaaaa |
{8: 5 }aaaaa |
{8: 6 }aaaaa |
{8: 7 }aaaaa |
{8: 8 }aaaaa |
|
]])
command('set nuw=1 stc=')
screen:expect_unchanged()
-- Correct alignment with items before and after number column
command([[set nu stc=foo\ %l\ bar]])
screen:expect([[
{8:foo 4 bar}aaaaa |
{8:foo 3 bar}aaaaa |
{8:foo 2 bar}aaaaa |
{8:foo 1 bar}aaaaa |
{8:foo 8 bar}^aaaaa |
{8:foo 1 bar}aaaaa |
{8:foo 2 bar}aaaaa |
{8:foo 3 bar}aaaaa |
{8:foo 4 bar}aaaaa |
{8:foo 5 bar}aaaaa |
{8:foo 6 bar}aaaaa |
{8:foo 7 bar}aaaaa |
{8:foo 8 bar}aaaaa |
|
]])
end) end)
it("works with highlighted 'statuscolumn'", function() it("works with highlighted 'statuscolumn'", function()
@@ -177,19 +211,19 @@ describe('statuscolumn', function()
]]) ]])
command('set nonumber') command('set nonumber')
screen:expect([[ screen:expect([[
{8:4│}aaaaa | {1: }{8:4│}aaaaa |
{1: 3}{8:│}aaaaa | {1: 3}{8:│}aaaaa |
{8:2│}aaaaa | {1: }{8:2│}aaaaa |
{1: 1}{8:│}aaaaa | {1: 1}{8:│}aaaaa |
{8:0│}^aaaaa | {1: }{8:0│}^aaaaa |
{1: 1}{8:│}aaaaa | {1: 1}{8:│}aaaaa |
{8:2│}aaaaa | {1: }{8:2│}aaaaa |
{1: 3}{8:│}aaaaa | {1: 3}{8:│}aaaaa |
{8:4│}aaaaa | {1: }{8:4│}aaaaa |
{1: 5}{8:│}aaaaa | {1: 5}{8:│}aaaaa |
{8:6│}aaaaa | {1: }{8:6│}aaaaa |
{1: 7}{8:│}aaaaa | {1: 7}{8:│}aaaaa |
{8:8│}aaaaa | {1: }{8:8│}aaaaa |
| |
]]) ]])
end) end)
@@ -305,36 +339,36 @@ describe('statuscolumn', function()
-- v:relnum is the same value on wrapped lines -- v:relnum is the same value on wrapped lines
command([[set stc=%C%=\ %{v:relnum}│%s\ ]]) command([[set stc=%C%=\ %{v:relnum}│%s\ ]])
screen:expect([[ screen:expect([[
{2: }{1: 4│>>}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: 4│>>}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }{1: 4│}{2: }{1: }aaaaaa | {2: }{1: 4│}{2: }{1: }aaaaaaa |
{2: }{1: 3│}{0:>!}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: 3│}{0:>!}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }{1: 3│}{2: }{1: }aaaaaa | {2: }{1: 3│}{2: }{1: }aaaaaaa |
{2: }{1: 2│}{0:>!}{1:>> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: 2│}{0:>!}{1:>> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }{1: 2│}{2: }{1: }aaaaaa | {2: }{1: 2│}{2: }{1: }aaaaaaa |
{2: }{1: 1│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: 1│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }{1: 1│}{2: }{1: }aaaaaa | {2: }{1: 1│}{2: }{1: }aaaaaaa |
{2:+}{4: 0│}{2: }{4: }{6:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| {2:+}{4: 0│}{2: }{4: }{6:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{2: }{1: 1│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: 1│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }{1: 1│}{2: }{1: }aaaaaa | {2: }{1: 1│}{2: }{1: }aaaaaaa |
{2: }{1: 2│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: 2│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }{1: 2│}{2: }{1: }aaaaaa | {2: }{1: 2│}{2: }{1: }aaaaaaa |
| |
]]) ]])
command([[set stc=%C%=\ %{v:virtnum?'':v:relnum}│%s\ ]]) command([[set stc=%C%=\ %{v:virtnum?'':v:relnum}│%s\ ]])
screen:expect([[ screen:expect([[
{2: }{1: 4│>>}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: 4│>>}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }{1: │}{2: }{1: }aaaaaa | {2: }{1: │}{2: }{1: }aaaaaaa |
{2: }{1: 3│}{0:>!}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: 3│}{0:>!}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }{1: │}{2: }{1: }aaaaaa | {2: }{1: │}{2: }{1: }aaaaaaa |
{2: }{1: 2│}{0:>!}{1:>> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: 2│}{0:>!}{1:>> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }{1: │}{2: }{1: }aaaaaa | {2: }{1: │}{2: }{1: }aaaaaaa |
{2: }{1: 1│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: 1│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }{1: │}{2: }{1: }aaaaaa | {2: }{1: │}{2: }{1: }aaaaaaa |
{2:+}{4: 0│}{2: }{4: }{6:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| {2:+}{4: 0│}{2: }{4: }{6:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{2: }{1: 1│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: 1│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }{1: │}{2: }{1: }aaaaaa | {2: }{1: │}{2: }{1: }aaaaaaa |
{2: }{1: 2│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: 2│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }{1: │}{2: }{1: }aaaaaa | {2: }{1: │}{2: }{1: }aaaaaaa |
| |
]]) ]])
-- Up to 9 signs in a line -- Up to 9 signs in a line
@@ -347,75 +381,75 @@ describe('statuscolumn', function()
command('sign place 10 line=6 name=piet2 buffer=1') command('sign place 10 line=6 name=piet2 buffer=1')
command('sign place 11 line=6 name=piet1 buffer=1') command('sign place 11 line=6 name=piet1 buffer=1')
screen:expect([[ screen:expect([[
{2: }{1: 4│>>}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: 4│>>}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }{1: │}{2: }{1: }aaaaaaaaaaaaaaaaaaaa | {2: }{1: │}{2: }{1: }aaaaaaaaaaaaaaaaaaaaa |
{2: }{1: 3│}{0:>!}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: 3│}{0:>!}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }{1: │}{2: }{1: }aaaaaaaaaaaaaaaaaaaa | {2: }{1: │}{2: }{1: }aaaaaaaaaaaaaaaaaaaaa |
{2: }{1: 2│>>}{0:>!}{1:>>}{0:>!}{1:>>}{0:>!}{1:>>}{0:>!}{1:>> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: 2│>>}{0:>!}{1:>>}{0:>!}{1:>>}{0:>!}{1:>>}{0:>!}{1:>> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }{1: │}{2: }{1: }aaaaaaaaaaaaaaaaaaaa | {2: }{1: │}{2: }{1: }aaaaaaaaaaaaaaaaaaaaa |
{2: }{1: 1│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: 1│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }{1: │}{2: }{1: }aaaaaaaaaaaaaaaaaaaa | {2: }{1: │}{2: }{1: }aaaaaaaaaaaaaaaaaaaaa |
{2:+}{4: 0│}{2: }{4: }{6:^+-- 1 line: aaaaaaaaaaaaaaaaa}| {2:+}{4: 0│}{2: }{4: }{6:^+-- 1 line: aaaaaaaaaaaaaaaa}|
{2: }{1: 1│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: 1│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }{1: │}{2: }{1: }aaaaaaaaaaaaaaaaaaaa | {2: }{1: │}{2: }{1: }aaaaaaaaaaaaaaaaaaaaa |
{2: }{1: 2│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: 2│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }{1: │}{2: }{1: }aaaaaaaaaaaaaaaaaaaa | {2: }{1: │}{2: }{1: }aaaaaaaaaaaaaaaaaaaaa |
| |
]]) ]])
-- Also test fold and sign column when 'cpoptions' includes "n" -- Also test fold and sign column when 'cpoptions' includes "n"
command('set cpoptions+=n') command('set cpoptions+=n')
feed('Hgjg0') feed('Hgjg0')
screen:expect([[ screen:expect([[
{2: }{4: 0│}{1:>>}{2: }{4: }{5:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| {2: }{4: 0│}{1:>>}{2: }{4: }{5:aaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{2: }{5:^aaaaaaaaaaaaaaaaaaaa }| {2: }{5:^aaaaaaaaaaaaaaaaaaaaa }|
{2: }{1: 3│}{0:>!}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: 3│}{0:>!}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }aaaaaaaaaaaaaaaaaaaa | {2: }aaaaaaaaaaaaaaaaaaaaa |
{2: }{1: 2│>>}{0:>!}{1:>>}{0:>!}{1:>>}{0:>!}{1:>>}{0:>!}{1:>> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: 2│>>}{0:>!}{1:>>}{0:>!}{1:>>}{0:>!}{1:>>}{0:>!}{1:>> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }aaaaaaaaaaaaaaaaaaaa | {2: }aaaaaaaaaaaaaaaaaaaaa |
{2: }{1: 1│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: 1│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }aaaaaaaaaaaaaaaaaaaa | {2: }aaaaaaaaaaaaaaaaaaaaa |
{2:+}{1: 4│}{2: }{1: }{3:+-- 1 line: aaaaaaaaaaaaaaaaa}| {2:+}{1: 4│}{2: }{1: }{3:+-- 1 line: aaaaaaaaaaaaaaaa}|
{2: }{1: 1│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: 1│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }aaaaaaaaaaaaaaaaaaaa | {2: }aaaaaaaaaaaaaaaaaaaaa |
{2: }{1: 2│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: 2│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }aaaaaaaaaaaaaaaaaaaa | {2: }aaaaaaaaaaaaaaaaaaaaa |
| |
]]) ]])
command('set breakindent') command('set breakindent')
command('sign unplace 2') command('sign unplace 2')
feed('J2gjg0') feed('J2gjg0')
screen:expect([[ screen:expect([[
{2: }{4: 0│}{1:>>}{2: }{4: }{5:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| {2: }{4: 0│}{1:>>}{2: }{4: }{5:aaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{2: } {5:aaaaaaaaaaaaaaaaaaaaa aaaaaaa}|
{2: } {5:aaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| {2: } {5:aaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{2: } {5:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| {2: } {5:^aaaaaaaaaaaaaa }|
{2: } {5:^aaaaaaaaaaa }| {2: }{1: 1│>>}{0:>!}{1:>>}{0:>!}{1:>>}{0:>!}{1:>>}{0:>!}{1:>> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }{1: 1│>>}{0:>!}{1:>>}{0:>!}{1:>>}{0:>!}{1:>>}{0:>!}{1:>> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: } aaaaaaaaaaaaaaaaaaaaa |
{2: } aaaaaaaaaaaaaaaaaaaa | {2: }{1: 2│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }{1: 2│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: } aaaaaaaaaaaaaaaaaaaaa |
{2: } aaaaaaaaaaaaaaaaaaaa | {2:+}{1: 3│}{2: }{1: }{3:+-- 1 line: aaaaaaaaaaaaaaaa}|
{2:+}{1: 3│}{2: }{1: }{3:+-- 1 line: aaaaaaaaaaaaaaaaa}| {2: }{1: 4│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }{1: 4│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: } aaaaaaaaaaaaaaaaaaaaa |
{2: } aaaaaaaaaaaaaaaaaaaa | {2: }{1: 5│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }{1: 5│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: } aaaaaaaaaaaaaaaaaaaaa |
{2: } aaaaaaaaaaaaaaaaaaaa |
| |
]]) ]])
command('set nobreakindent') command('set nobreakindent')
feed('$g0') feed('$g0')
screen:expect([[ screen:expect([[
{2: }{4: 0│}{1:>>}{2: }{4: }{5:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| {2: }{4: 0│}{1:>>}{2: }{4: }{5:aaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{2: }{5:aaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaa}| {2: }{5:aaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaa}|
{2: }{5:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| {2: }{5:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{2: }{5:^aaa }| {2: }{5:^aaaa }|
{2: }{1: 1│>>}{0:>!}{1:>>}{0:>!}{1:>>}{0:>!}{1:>>}{0:>!}{1:>> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: 1│>>}{0:>!}{1:>>}{0:>!}{1:>>}{0:>!}{1:>>}{0:>!}{1:>> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }aaaaaaaaaaaaaaaaaaaa | {2: }aaaaaaaaaaaaaaaaaaaaa |
{2: }{1: 2│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: 2│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }aaaaaaaaaaaaaaaaaaaa | {2: }aaaaaaaaaaaaaaaaaaaaa |
{2:+}{1: 3│}{2: }{1: }{3:+-- 1 line: aaaaaaaaaaaaaaaaa}| {2:+}{1: 3│}{2: }{1: }{3:+-- 1 line: aaaaaaaaaaaaaaaa}|
{2: }{1: 4│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: 4│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }aaaaaaaaaaaaaaaaaaaa | {2: }aaaaaaaaaaaaaaaaaaaaa |
{2: }{1: 5│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: 5│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{2: }aaaaaaaaaaaaaaaaaaaa | {2: }aaaaaaaaaaaaaaaaaaaaa |
| |
]]) ]])
command('silent undo') command('silent undo')
@@ -427,7 +461,23 @@ describe('statuscolumn', function()
virt_lines_above = true, virt_lines = {{{"virt_line above", ""}}} }) virt_lines_above = true, virt_lines = {{{"virt_line above", ""}}} })
vim.api.nvim_buf_set_extmark(0, ns, 4, 0, { virt_lines = {{{"virt_line", ""}}} }) vim.api.nvim_buf_set_extmark(0, ns, 4, 0, { virt_lines = {{{"virt_line", ""}}} })
]]) ]])
command('set foldcolumn=0 signcolumn=no') command('set foldcolumn=0 signcolumn=number stc=%l')
screen:expect([[
{1:>>}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
{1: 5}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
{1: }virt_line |
{1: }virt_line above |
{1:>>}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
{1: 7}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
{4: 8}{6:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{1: 9}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
{1:10}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
{1:11}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
{1:12}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
{1:13}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
{1:14}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
|
]])
command( command(
[[set stc=%{v:virtnum<0?'virtual':(!v:virtnum?'buffer':'wrapped')}%=%{'\ '.v:virtnum.'\ '.v:lnum}]] [[set stc=%{v:virtnum<0?'virtual':(!v:virtnum?'buffer':'wrapped')}%=%{'\ '.v:virtnum.'\ '.v:lnum}]]
) )
@@ -908,7 +958,7 @@ describe('statuscolumn', function()
it('line increase properly redraws buffer text with relativenumber #27709', function() it('line increase properly redraws buffer text with relativenumber #27709', function()
screen:try_resize(33, 4) screen:try_resize(33, 4)
command([[set rnu nuw=3 stc=%l\ ]]) command([[set rnu nuw=3 stc=%{v:lnum}\ ]])
command('call setline(1, range(1, 99))') command('call setline(1, range(1, 99))')
feed('Gyyp') feed('Gyyp')
screen:expect([[ screen:expect([[