mirror of
https://github.com/neovim/neovim.git
synced 2024-12-29 14:41:06 -07:00
fix(column): set signcolumn width after splitting window (#30556)
(cherry picked from commit d5f6f61879
)
This commit is contained in:
parent
28fba3bf27
commit
1fc09b0738
@ -300,26 +300,26 @@ int check_signcolumn(win_T *wp)
|
|||||||
wp->w_minscwidth = 0;
|
wp->w_minscwidth = 0;
|
||||||
wp->w_maxscwidth = 1;
|
wp->w_maxscwidth = 1;
|
||||||
}
|
}
|
||||||
return OK;
|
} else {
|
||||||
|
if (strncmp(val, "auto:", 5) != 0
|
||||||
|
|| strlen(val) != 8
|
||||||
|
|| !ascii_isdigit(val[5])
|
||||||
|
|| val[6] != '-'
|
||||||
|
|| !ascii_isdigit(val[7])) {
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
// auto:<NUM>-<NUM>
|
||||||
|
int min = val[5] - '0';
|
||||||
|
int max = val[7] - '0';
|
||||||
|
if (min < 1 || max < 2 || min > 8 || min >= max) {
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
wp->w_minscwidth = min;
|
||||||
|
wp->w_maxscwidth = max;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strncmp(val, "auto:", 5) != 0
|
int scwidth = wp->w_minscwidth <= 0 ? 0 : MIN(wp->w_maxscwidth, wp->w_scwidth);
|
||||||
|| strlen(val) != 8
|
wp->w_scwidth = MAX(wp->w_minscwidth, scwidth);
|
||||||
|| !ascii_isdigit(val[5])
|
|
||||||
|| val[6] != '-'
|
|
||||||
|| !ascii_isdigit(val[7])) {
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// auto:<NUM>-<NUM>
|
|
||||||
int min = val[5] - '0';
|
|
||||||
int max = val[7] - '0';
|
|
||||||
if (min < 1 || max < 2 || min > 8 || min >= max) {
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
wp->w_minscwidth = min;
|
|
||||||
wp->w_maxscwidth = max;
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2019,8 +2019,6 @@ const char *did_set_signcolumn(optset_T *args)
|
|||||||
if (check_signcolumn(win) != OK) {
|
if (check_signcolumn(win) != OK) {
|
||||||
return e_invarg;
|
return e_invarg;
|
||||||
}
|
}
|
||||||
int scwidth = win->w_minscwidth <= 0 ? 0 : MIN(win->w_maxscwidth, win->w_scwidth);
|
|
||||||
win->w_scwidth = MAX(win->w_minscwidth, scwidth);
|
|
||||||
// When changing the 'signcolumn' to or from 'number', recompute the
|
// When changing the 'signcolumn' to or from 'number', recompute the
|
||||||
// width of the number column if 'number' or 'relativenumber' is set.
|
// width of the number column if 'number' or 'relativenumber' is set.
|
||||||
if ((*oldval == 'n' && *(oldval + 1) == 'u') || win->w_minscwidth == SCL_NUM) {
|
if ((*oldval == 'n' && *(oldval + 1) == 'u') || win->w_minscwidth == SCL_NUM) {
|
||||||
|
@ -4,6 +4,7 @@ local Screen = require('test.functional.ui.screen')
|
|||||||
|
|
||||||
local api, clear, eq = n.api, n.clear, t.eq
|
local api, clear, eq = n.api, n.clear, t.eq
|
||||||
local eval, exec, feed = n.eval, n.exec, n.feed
|
local eval, exec, feed = n.eval, n.exec, n.feed
|
||||||
|
local exec_lua = n.exec_lua
|
||||||
|
|
||||||
describe('Signs', function()
|
describe('Signs', function()
|
||||||
local screen
|
local screen
|
||||||
@ -607,4 +608,15 @@ describe('Signs', function()
|
|||||||
exec('sign unplace 1')
|
exec('sign unplace 1')
|
||||||
screen:expect(s1)
|
screen:expect(s1)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('signcolumn width is set immediately after splitting window #30547', function()
|
||||||
|
local infos = exec_lua([[
|
||||||
|
vim.o.number = true
|
||||||
|
vim.o.signcolumn = 'yes'
|
||||||
|
vim.cmd.wincmd('v')
|
||||||
|
return vim.fn.getwininfo()
|
||||||
|
]])
|
||||||
|
eq(6, infos[1].textoff)
|
||||||
|
eq(6, infos[2].textoff)
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user