diff options
author | Luuk van Baal <luukvbaal@gmail.com> | 2023-11-20 02:27:16 +0100 |
---|---|---|
committer | Lewis Russell <me@lewisr.dev> | 2023-11-21 09:38:32 +0000 |
commit | 585eeacb24e1aa0fed978e46063de100b16b8bdf (patch) | |
tree | 023df9778c072cef7fa36d4b23ed96d5a9dc2997 /src/nvim/option.c | |
parent | fec5e3ab247bcc1ced67f1d0aa7fa10f694f933b (diff) | |
download | rneovim-585eeacb24e1aa0fed978e46063de100b16b8bdf.tar.gz rneovim-585eeacb24e1aa0fed978e46063de100b16b8bdf.tar.bz2 rneovim-585eeacb24e1aa0fed978e46063de100b16b8bdf.zip |
refactor(sign): store 'signcolumn' width range when it is set
Problem: Minimum and maximum signcolumn width is determined each redraw.
Solution: Determine and store 'signcolumn' range when option is set.
Diffstat (limited to 'src/nvim/option.c')
-rw-r--r-- | src/nvim/option.c | 45 |
1 files changed, 5 insertions, 40 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c index a920912452..0fae498b25 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -2245,6 +2245,7 @@ static const char *did_set_number_relativenumber(optset_T *args) // When 'relativenumber'/'number' is changed and 'statuscolumn' is set, reset width. win->w_nrwidth_line_count = 0; } + check_signcolumn(win); return NULL; } @@ -4861,6 +4862,7 @@ void didset_window_options(win_T *wp, bool valid_cursor) parse_winhl_opt(wp); // sets w_hl_needs_update also for w_p_winbl check_blending(wp); set_winbar_win(wp, false, valid_cursor); + check_signcolumn(wp); wp->w_grid_alloc.blending = wp->w_p_winbl > 0; } @@ -6170,49 +6172,12 @@ bool fish_like_shell(void) /// buffer signs and on user configuration. int win_signcol_count(win_T *wp) { - return win_signcol_configured(wp); -} - -/// Return true when window "wp" has no sign column. -bool win_no_signcol(win_T *wp) -{ - const char *scl = wp->w_p_scl; - return (*scl == 'n' && (*(scl + 1) == 'o' || (*(scl + 1) == 'u' - && (wp->w_p_nu || wp->w_p_rnu)))); -} - -/// Return the number of requested sign columns, based on user / configuration. -int win_signcol_configured(win_T *wp) -{ - const char *scl = wp->w_p_scl; - - if (win_no_signcol(wp)) { + if (wp->w_minscwidth <= SCL_NO) { return 0; } - // yes or yes - if (!strncmp(scl, "yes:", 4)) { - // Fixed amount of columns - return scl[4] - '0'; - } - if (*scl == 'y') { - return 1; - } - - int minimum = 0, maximum = 1; - - if (!strncmp(scl, "auto:", 5)) { - // Variable depending on a configuration - maximum = scl[5] - '0'; - // auto:<NUM>-<NUM> - if (strlen(scl) == 8 && *(scl + 6) == '-') { - minimum = maximum; - maximum = scl[7] - '0'; - } - } - - int needed_signcols = buf_signcols(wp->w_buffer, maximum); - int ret = MAX(minimum, MIN(maximum, needed_signcols)); + int needed_signcols = buf_signcols(wp->w_buffer, wp->w_maxscwidth); + int ret = MAX(wp->w_minscwidth, MIN(wp->w_maxscwidth, needed_signcols)); assert(ret <= SIGN_SHOW_MAX); return ret; } |