From 37a00be7c0bff9c33c2c679561e6bf53c648c271 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 24 Dec 2021 22:38:15 -0700 Subject: [PATCH] fix(options): disallow empty 'fdc' and 'scl' (#16776) Empty string values for these options aren't actually allowed, but check_opt_strings allows empty string options. It so happens that 'scl' handles empty string like "auto", but empty 'fdc' causes glitchiness (win_fdccol_count returns an incorrect value). Just disallow empty string values for these options completely. --- src/nvim/option.c | 5 ++++- test/functional/legacy/options_spec.lua | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/nvim/option.c b/src/nvim/option.c index 45e2032b35..4a2a772c8c 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -2953,7 +2953,7 @@ ambw_end: } } else if (varp == &curwin->w_p_fdc || varp == &curwin->w_allbuf_opt.wo_fdc) { // 'foldcolumn' - if (check_opt_strings(*varp, p_fdc_values, false) != OK) { + if (**varp == NUL || check_opt_strings(*varp, p_fdc_values, false) != OK) { errmsg = e_invarg; } } else if (varp == &p_pt) { @@ -3332,6 +3332,9 @@ static int int_cmp(const void *a, const void *b) /// @return OK when the value is valid, FAIL otherwise int check_signcolumn(char_u *val) { + if (*val == NUL) { + return FAIL; + } // check for basic match if (check_opt_strings(val, p_scl_values, false) == OK) { return OK; diff --git a/test/functional/legacy/options_spec.lua b/test/functional/legacy/options_spec.lua index 023cdd4ae1..bd14f3bc53 100644 --- a/test/functional/legacy/options_spec.lua +++ b/test/functional/legacy/options_spec.lua @@ -83,4 +83,9 @@ describe('set', function() Press ENTER or type command to continue^ | ]]) end) + + it('foldcolumn and signcolumn to empty string is disallowed', function() + matches('E474: Invalid argument: fdc=', exc_exec('set fdc=')) + matches('E474: Invalid argument: scl=', exc_exec('set scl=')) + end) end)