diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-11-22 03:08:29 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-11-22 03:08:29 +0100 |
commit | f951416a8396a54bbbe21de1a8b16716428549f2 (patch) | |
tree | 2903bb024e534d4a4c5004beef72f4dc38583b29 /src/option.c | |
parent | 2b84949ad8f247e5d142e2fb1371b3e37567977a (diff) | |
download | vim-git-f951416a8396a54bbbe21de1a8b16716428549f2.tar.gz |
patch 8.1.0542: shiftwidth() does not take 'vartabstop' into accountv8.1.0542
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)
Diffstat (limited to 'src/option.c')
-rw-r--r-- | src/option.c | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/src/option.c b/src/option.c index 50d405a95..fdb99addd 100644 --- a/src/option.c +++ b/src/option.c @@ -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 } /* |