aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthieu Coudron <teto@users.noreply.github.com>2021-01-23 22:46:29 +0100
committerGitHub <noreply@github.com>2021-01-23 22:46:29 +0100
commit69103ff0cf9e23e4f003c9f22f482b3d52bf7892 (patch)
treea304e3136e388666a85c3179c20fc128d703cc4c /src
parent444e60ab39ec44a51aa3606f007c9272743df6c9 (diff)
parent83ea08ddf30d6a2f5e4e8108fd546aa94aa0af94 (diff)
downloadrneovim-69103ff0cf9e23e4f003c9f22f482b3d52bf7892.tar.gz
rneovim-69103ff0cf9e23e4f003c9f22f482b3d52bf7892.tar.bz2
rneovim-69103ff0cf9e23e4f003c9f22f482b3d52bf7892.zip
Merge pull request #13807 from spywhere/min-size-auto-sign
Auto sign column with minimum size support
Diffstat (limited to 'src')
-rw-r--r--src/nvim/option.c39
1 files changed, 36 insertions, 3 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 47b9e9bb07..74bf6f0590 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -2913,7 +2913,7 @@ ambw_end:
#endif
} else if (varp == &curwin->w_p_scl) {
// 'signcolumn'
- if (check_opt_strings(*varp, p_scl_values, false) != OK) {
+ if (check_signcolumn(*varp) != OK) {
errmsg = e_invarg;
}
// When changing the 'signcolumn' to or from 'number', recompute the
@@ -3232,6 +3232,34 @@ static int int_cmp(const void *a, const void *b)
return *(const int *)a - *(const int *)b;
}
+/// Handle setting 'signcolumn' for value 'val'
+///
+/// @return OK when the value is valid, FAIL otherwise
+int check_signcolumn(char_u *val)
+{
+ // check for basic match
+ if (check_opt_strings(val, p_scl_values, false) == OK) {
+ return OK;
+ }
+
+ // check for 'auto:<NUMBER>-<NUMBER>'
+ if (STRLEN(val) == 8
+ && !STRNCMP(val, "auto:", 5)
+ && ascii_isdigit(val[5])
+ && val[6] == '-'
+ && ascii_isdigit(val[7])
+ ) {
+ int min = val[5] - '0';
+ int max = val[7] - '0';
+ if (min < 1 || max < 2 || min > 8 || max > 9 || min >= max) {
+ return FAIL;
+ }
+ return OK;
+ }
+
+ return FAIL;
+}
+
/// Handle setting 'colorcolumn' or 'textwidth' in window "wp".
///
/// @return error message, NULL if it's OK.
@@ -7095,7 +7123,7 @@ int csh_like_shell(void)
/// buffer signs and on user configuration.
int win_signcol_count(win_T *wp)
{
- int maximum = 1, needed_signcols;
+ int minimum = 0, maximum = 1, needed_signcols;
const char *scl = (const char *)wp->w_p_scl;
// Note: It checks "no" or "number" in 'signcolumn' option
@@ -7119,9 +7147,14 @@ int win_signcol_count(win_T *wp)
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';
+ }
}
- return MIN(maximum, needed_signcols);
+ return MAX(minimum, MIN(maximum, needed_signcols));
}
/// Get window or buffer local options