patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Problem: shiftwidth() does not take 'vartabstop' into account.
Solution: Use the cursor position or a position explicitly passed.
Also make >> and << work better with 'vartabstop'. (Christian
Brabandt)
diff --git a/src/evalfunc.c b/src/evalfunc.c
index f55739e..d3bacad 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -835,7 +835,7 @@
{"sha256", 1, 1, f_sha256},
#endif
{"shellescape", 1, 2, f_shellescape},
- {"shiftwidth", 0, 0, f_shiftwidth},
+ {"shiftwidth", 0, 1, f_shiftwidth},
{"simplify", 1, 1, f_simplify},
#ifdef FEAT_FLOAT
{"sin", 1, 1, f_sin},
@@ -11241,6 +11241,21 @@
static void
f_shiftwidth(typval_T *argvars UNUSED, typval_T *rettv)
{
+ rettv->vval.v_number = 0;
+
+ if (argvars[0].v_type != VAR_UNKNOWN)
+ {
+ long col;
+
+ col = (long)get_tv_number_chk(argvars, NULL);
+ if (col < 0)
+ return; // type error; errmsg already given
+#ifdef FEAT_VARTABS
+ rettv->vval.v_number = get_sw_value_col(curbuf, col);
+ return;
+#endif
+ }
+
rettv->vval.v_number = get_sw_value(curbuf);
}