mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
fix(statuscolumn): make %l/%r respect 'number'/'relativenumber' (#21747)
Resolve https://github.com/neovim/neovim/issues/21745.
This commit is contained in:
parent
449c0762d3
commit
4a12372ccf
@ -1502,8 +1502,14 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n
|
||||
|
||||
case STL_LINE:
|
||||
// Overload %l with v:lnum for 'statuscolumn'
|
||||
num = opt_name != NULL && strcmp(opt_name, "statuscolumn") == 0 ? get_vim_var_nr(VV_LNUM)
|
||||
: (wp->w_buffer->b_ml.ml_flags & ML_EMPTY) ? 0L : (long)(wp->w_cursor.lnum);
|
||||
if (opt_name != NULL && strcmp(opt_name, "statuscolumn") == 0) {
|
||||
if (wp->w_p_nu) {
|
||||
num = get_vim_var_nr(VV_LNUM);
|
||||
}
|
||||
} else {
|
||||
num = (wp->w_buffer->b_ml.ml_flags & ML_EMPTY) ? 0L : (long)(wp->w_cursor.lnum);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case STL_NUMLINES:
|
||||
@ -1603,7 +1609,9 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n
|
||||
case STL_ROFLAG_ALT:
|
||||
// Overload %r with v:relnum for 'statuscolumn'
|
||||
if (opt_name != NULL && strcmp(opt_name, "statuscolumn") == 0) {
|
||||
num = get_vim_var_nr(VV_RELNUM);
|
||||
if (wp->w_p_rnu) {
|
||||
num = get_vim_var_nr(VV_RELNUM);
|
||||
}
|
||||
} else {
|
||||
itemisflag = true;
|
||||
if (wp->w_buffer->b_p_ro) {
|
||||
|
@ -77,6 +77,9 @@ describe('statuscolumn', function()
|
||||
16│aaaaa |
|
||||
|
|
||||
]])
|
||||
command([[set stc=%l%=%{&rnu?'\ ':''}%r│]])
|
||||
screen:expect_unchanged()
|
||||
command([[set stc=%{&nu?v:lnum:''}%=%{&rnu?'\ '.v:relnum:''}│]])
|
||||
command('set relativenumber')
|
||||
screen:expect([[
|
||||
4 4│aaaaa |
|
||||
@ -94,6 +97,9 @@ describe('statuscolumn', function()
|
||||
16 8│aaaaa |
|
||||
|
|
||||
]])
|
||||
command([[set stc=%l%=%{&rnu?'\ ':''}%r│]])
|
||||
screen:expect_unchanged()
|
||||
command([[set stc=%{&nu?v:lnum:''}%=%{&rnu?'\ '.v:relnum:''}│]])
|
||||
command('norm 12GH')
|
||||
screen:expect([[
|
||||
4 0│^aaaaa |
|
||||
@ -111,6 +117,9 @@ describe('statuscolumn', function()
|
||||
16 12│aaaaa |
|
||||
|
|
||||
]])
|
||||
command([[set stc=%l%=%{&rnu?'\ ':''}%r│]])
|
||||
screen:expect_unchanged()
|
||||
command([[set stc=%{&nu?v:lnum:''}%=%{&rnu?'\ '.v:relnum:''}│]])
|
||||
end)
|
||||
|
||||
it('works with highlighted \'statuscolumn\'', function()
|
||||
|
Loading…
Reference in New Issue
Block a user