0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03: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

@@ -13113,7 +13113,48 @@ tabstop_first(int *ts)
long
get_sw_value(buf_T *buf)
{
return buf->b_p_sw ? buf->b_p_sw : buf->b_p_ts;
return get_sw_value_col(buf, 0);
}
/*
* Idem, using the first non-black in the current line.
*/
long
get_sw_value_indent(buf_T *buf)
{
pos_T pos = curwin->w_cursor;
pos.col = getwhitecols_curline();
return get_sw_value_pos(buf, &pos);
}
/*
* Idem, using "pos".
*/
long
get_sw_value_pos(buf_T *buf, pos_T *pos)
{
pos_T save_cursor = curwin->w_cursor;
long sw_value;
curwin->w_cursor = *pos;
sw_value = get_sw_value_col(buf, get_nolist_virtcol());
curwin->w_cursor = save_cursor;
return sw_value;
}
/*
* Idem, using virtual column "col".
*/
long
get_sw_value_col(buf_T *buf, colnr_T col UNUSED)
{
return buf->b_p_sw ? buf->b_p_sw :
#ifdef FEAT_VARTABS
tabstop_at(col, buf->b_p_ts, buf->b_p_vts_array);
#else
buf->b_p_ts;
#endif
}
/*