diff options
author | Matthieu Coudron <mattator@gmail.com> | 2020-01-14 19:50:30 +0100 |
---|---|---|
committer | Matthieu Coudron <mattator@gmail.com> | 2020-02-29 20:27:22 +0100 |
commit | 1a2be57da3f7e33af4e4eb3e0d36569feea71253 (patch) | |
tree | e38b97171e9539644e2be9eb36f02f17be2d13ee /src/nvim/option.c | |
parent | 49cd750d6a72efc0571a89d7a874bbb01081227f (diff) | |
download | rneovim-1a2be57da3f7e33af4e4eb3e0d36569feea71253.tar.gz rneovim-1a2be57da3f7e33af4e4eb3e0d36569feea71253.tar.bz2 rneovim-1a2be57da3f7e33af4e4eb3e0d36569feea71253.zip |
foldcolumn: allow auto:X
Similar to signcolumn, allow foldcolumn to adapt itself to the number of
folds.
Regression:
vim supports a maximum fdc of 12, this limits it to 9.
Diffstat (limited to 'src/nvim/option.c')
-rw-r--r-- | src/nvim/option.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c index 478c9a0ff8..e990cb5214 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -315,6 +315,9 @@ 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", NULL }; +static char *(p_fdc_values[]) = { "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 }; /// All possible flags for 'shm'. static char_u SHM_ALL[] = { @@ -2322,6 +2325,7 @@ void check_buf_options(buf_T *buf) * Does NOT check for P_ALLOCED flag! */ void free_string_option(char_u *p) + { if (p != empty_option) { xfree(p); @@ -3199,6 +3203,11 @@ ambw_end: if (check_opt_strings(*varp, p_scl_values, false) != OK) { errmsg = e_invarg; } + } 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) { + errmsg = e_invarg; + } } else if (varp == &p_pt) { // 'pastetoggle': translate key codes like in a mapping if (*p_pt) { @@ -4363,12 +4372,6 @@ static char *set_num_option(int opt_idx, char_u *varp, long value, if (value < 0) { errmsg = e_positive; } - } else if (pp == &curwin->w_p_fdc || pp == &curwin->w_allbuf_opt.wo_fdc) { - if (value < 0) { - errmsg = e_positive; - } else if (value > 12) { - errmsg = e_invarg; - } } else if (pp == &curwin->w_p_cole || pp == &curwin->w_allbuf_opt.wo_cole) { if (value < 0) { errmsg = e_positive; @@ -5936,8 +5939,9 @@ void copy_winopt(winopt_T *from, winopt_T *to) to->wo_diff_saved = from->wo_diff_saved; to->wo_cocu = vim_strsave(from->wo_cocu); to->wo_cole = from->wo_cole; - to->wo_fdc = from->wo_fdc; - to->wo_fdc_save = from->wo_fdc_save; + to->wo_fdc = vim_strsave(from->wo_fdc); + to->wo_fdc_save = from->wo_diff_saved + ? vim_strsave(from->wo_fdc_save) : empty_option; to->wo_fen = from->wo_fen; to->wo_fen_save = from->wo_fen_save; to->wo_fdi = vim_strsave(from->wo_fdi); @@ -5973,6 +5977,8 @@ void check_win_options(win_T *win) */ static void check_winopt(winopt_T *wop) { + check_string_option(&wop->wo_fdc); + check_string_option(&wop->wo_fdc_save); check_string_option(&wop->wo_fdi); check_string_option(&wop->wo_fdm); check_string_option(&wop->wo_fdm_save); @@ -5995,6 +6001,8 @@ static void check_winopt(winopt_T *wop) */ void clear_winopt(winopt_T *wop) { + clear_string_option(&wop->wo_fdc); + clear_string_option(&wop->wo_fdc_save); clear_string_option(&wop->wo_fdi); clear_string_option(&wop->wo_fdm); clear_string_option(&wop->wo_fdm_save); |