diff src/evalfunc.c @ 15062:3a94f7918980 v8.1.0542

patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account commit https://github.com/vim/vim/commit/f951416a8396a54bbbe21de1a8b16716428549f2 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Nov 22 03:08:29 2018 +0100 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)
author Bram Moolenaar <Bram@vim.org>
date Thu, 22 Nov 2018 03:15:10 +0100
parents 1b112e7366c0
children 2fed75dee954
line wrap: on
line diff
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -835,7 +835,7 @@ static struct fst
     {"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 @@ f_shellescape(typval_T *argvars, typval_
     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);
 }