mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
foldcolumn: support "auto" (#13571)
"set foldcolumn=auto" is documented but not supported. Support it by making it behave as "auto:1", similar to "signcolumn". Close https://github.com/neovim/neovim/pull/13561
This commit is contained in:
parent
abcbc5a9f3
commit
b1711e6f92
@ -2438,7 +2438,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
'foldcolumn' 'fdc' string (default "0")
|
'foldcolumn' 'fdc' string (default "0")
|
||||||
local to window
|
local to window
|
||||||
When and how to draw the foldcolumn. Valid values are:
|
When and how to draw the foldcolumn. Valid values are:
|
||||||
"auto": resize to the maximum amount of folds to display.
|
"auto": resize to the minimum amount of folds to display.
|
||||||
"auto:[1-9]": resize to accommodate multiple folds up to the
|
"auto:[1-9]": resize to accommodate multiple folds up to the
|
||||||
selected level
|
selected level
|
||||||
0: to disable foldcolumn
|
0: to disable foldcolumn
|
||||||
|
@ -320,7 +320,7 @@ static char *(p_scl_values[]) = { "yes", "no", "auto", "auto:1", "auto:2",
|
|||||||
"auto:3", "auto:4", "auto:5", "auto:6", "auto:7", "auto:8", "auto:9",
|
"auto:3", "auto:4", "auto:5", "auto:6", "auto:7", "auto:8", "auto:9",
|
||||||
"yes:1", "yes:2", "yes:3", "yes:4", "yes:5", "yes:6", "yes:7", "yes:8",
|
"yes:1", "yes:2", "yes:3", "yes:4", "yes:5", "yes:6", "yes:7", "yes:8",
|
||||||
"yes:9", "number", NULL };
|
"yes:9", "number", NULL };
|
||||||
static char *(p_fdc_values[]) = { "auto:1", "auto:2",
|
static char *(p_fdc_values[]) = { "auto", "auto:1", "auto:2",
|
||||||
"auto:3", "auto:4", "auto:5", "auto:6", "auto:7", "auto:8", "auto:9",
|
"auto:3", "auto:4", "auto:5", "auto:6", "auto:7", "auto:8", "auto:9",
|
||||||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL };
|
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL };
|
||||||
|
|
||||||
|
@ -641,7 +641,7 @@ void win_set_minimal_style(win_T *wp)
|
|||||||
wp->w_p_scl = (char_u *)xstrdup("auto");
|
wp->w_p_scl = (char_u *)xstrdup("auto");
|
||||||
}
|
}
|
||||||
|
|
||||||
// foldcolumn: use 'auto'
|
// foldcolumn: use '0'
|
||||||
if (wp->w_p_fdc[0] != '0') {
|
if (wp->w_p_fdc[0] != '0') {
|
||||||
xfree(wp->w_p_fdc);
|
xfree(wp->w_p_fdc);
|
||||||
wp->w_p_fdc = (char_u *)xstrdup("0");
|
wp->w_p_fdc = (char_u *)xstrdup("0");
|
||||||
@ -700,9 +700,10 @@ int win_fdccol_count(win_T *wp)
|
|||||||
const char *fdc = (const char *)wp->w_p_fdc;
|
const char *fdc = (const char *)wp->w_p_fdc;
|
||||||
|
|
||||||
// auto:<NUM>
|
// auto:<NUM>
|
||||||
if (strncmp(fdc, "auto:", 5) == 0) {
|
if (strncmp(fdc, "auto", 4) == 0) {
|
||||||
|
const int fdccol = fdc[4] == ':' ? fdc[5] - '0' : 1;
|
||||||
int needed_fdccols = getDeepestNesting(wp);
|
int needed_fdccols = getDeepestNesting(wp);
|
||||||
return MIN(fdc[5] - '0', needed_fdccols);
|
return MIN(fdccol, needed_fdccols);
|
||||||
} else {
|
} else {
|
||||||
return fdc[0] - '0';
|
return fdc[0] - '0';
|
||||||
}
|
}
|
||||||
|
@ -886,6 +886,41 @@ describe("folded lines", function()
|
|||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
end
|
end
|
||||||
|
command("set foldcolumn=auto")
|
||||||
|
if multigrid then
|
||||||
|
screen:expect{grid=[[
|
||||||
|
## grid 1
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[3:---------------------------------------------]|
|
||||||
|
## grid 2
|
||||||
|
{7:+}{5:^+-- 2 lines: line 1························}|
|
||||||
|
{7: }line 3 |
|
||||||
|
{7: }line 4 |
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
## grid 3
|
||||||
|
|
|
||||||
|
]], unchanged=true}
|
||||||
|
else
|
||||||
|
screen:expect{grid=[[
|
||||||
|
{7:+}{5:^+-- 2 lines: line 1························}|
|
||||||
|
{7: }line 3 |
|
||||||
|
{7: }line 4 |
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
|
|
||||||
|
]], unchanged=true}
|
||||||
|
end
|
||||||
-- fdc should not change with a new fold as the maximum is 1
|
-- fdc should not change with a new fold as the maximum is 1
|
||||||
feed("zf3j")
|
feed("zf3j")
|
||||||
|
|
||||||
@ -924,6 +959,41 @@ describe("folded lines", function()
|
|||||||
]])
|
]])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
command("set foldcolumn=auto:1")
|
||||||
|
if multigrid then screen:expect{grid=[[
|
||||||
|
## grid 1
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[3:---------------------------------------------]|
|
||||||
|
## grid 2
|
||||||
|
{7:+}{5:^+-- 4 lines: line 1························}|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
## grid 3
|
||||||
|
|
|
||||||
|
]], unchanged=true}
|
||||||
|
else
|
||||||
|
screen:expect{grid=[[
|
||||||
|
{7:+}{5:^+-- 4 lines: line 1························}|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
|
|
||||||
|
]], unchanged=true}
|
||||||
|
end
|
||||||
|
|
||||||
-- relax the maximum fdc thus fdc should expand to
|
-- relax the maximum fdc thus fdc should expand to
|
||||||
-- accomodate the current number of folds
|
-- accomodate the current number of folds
|
||||||
command("set foldcolumn=auto:4")
|
command("set foldcolumn=auto:4")
|
||||||
|
Loading…
Reference in New Issue
Block a user