From b1711e6f922598f00c4d2c879094afdbba44c187 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 20 Dec 2020 15:20:42 -0500 Subject: 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 --- src/nvim/option.c | 2 +- src/nvim/window.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/option.c b/src/nvim/option.c index 7cf8412269..bac289a959 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -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", "yes:1", "yes:2", "yes:3", "yes:4", "yes:5", "yes:6", "yes:7", "yes:8", "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", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL }; diff --git a/src/nvim/window.c b/src/nvim/window.c index 9eb16e67ec..0f17e2cb09 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -641,7 +641,7 @@ void win_set_minimal_style(win_T *wp) wp->w_p_scl = (char_u *)xstrdup("auto"); } - // foldcolumn: use 'auto' + // foldcolumn: use '0' if (wp->w_p_fdc[0] != '0') { xfree(wp->w_p_fdc); 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; // auto: - 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); - return MIN(fdc[5] - '0', needed_fdccols); + return MIN(fdccol, needed_fdccols); } else { return fdc[0] - '0'; } -- cgit