0
0
mirror of https://github.com/vim/vim.git synced 2025-10-13 06:54:15 -04:00

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)
This commit is contained in:
Bram Moolenaar
2018-11-22 03:08:29 +01:00
parent 2b84949ad8
commit f951416a83
11 changed files with 154 additions and 17 deletions

View File

@@ -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_T *rettv)
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);
}