comparison src/option.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 5997b84a838a
children 40d9218b2b12
comparison
equal deleted inserted replaced
15061:0572862c3162 15062:3a94f7918980
13111 * 'tabstop' value when 'shiftwidth' is zero. 13111 * 'tabstop' value when 'shiftwidth' is zero.
13112 */ 13112 */
13113 long 13113 long
13114 get_sw_value(buf_T *buf) 13114 get_sw_value(buf_T *buf)
13115 { 13115 {
13116 return buf->b_p_sw ? buf->b_p_sw : buf->b_p_ts; 13116 return get_sw_value_col(buf, 0);
13117 }
13118
13119 /*
13120 * Idem, using the first non-black in the current line.
13121 */
13122 long
13123 get_sw_value_indent(buf_T *buf)
13124 {
13125 pos_T pos = curwin->w_cursor;
13126
13127 pos.col = getwhitecols_curline();
13128 return get_sw_value_pos(buf, &pos);
13129 }
13130
13131 /*
13132 * Idem, using "pos".
13133 */
13134 long
13135 get_sw_value_pos(buf_T *buf, pos_T *pos)
13136 {
13137 pos_T save_cursor = curwin->w_cursor;
13138 long sw_value;
13139
13140 curwin->w_cursor = *pos;
13141 sw_value = get_sw_value_col(buf, get_nolist_virtcol());
13142 curwin->w_cursor = save_cursor;
13143 return sw_value;
13144 }
13145
13146 /*
13147 * Idem, using virtual column "col".
13148 */
13149 long
13150 get_sw_value_col(buf_T *buf, colnr_T col UNUSED)
13151 {
13152 return buf->b_p_sw ? buf->b_p_sw :
13153 #ifdef FEAT_VARTABS
13154 tabstop_at(col, buf->b_p_ts, buf->b_p_vts_array);
13155 #else
13156 buf->b_p_ts;
13157 #endif
13117 } 13158 }
13118 13159
13119 /* 13160 /*
13120 * Return the effective softtabstop value for the current buffer, using the 13161 * Return the effective softtabstop value for the current buffer, using the
13121 * 'shiftwidth' value when 'softtabstop' is negative. 13162 * 'shiftwidth' value when 'softtabstop' is negative.