forked from aniani/vim
patch 9.1.0456: Left shift is incorrect with vartabstop and shiftwidth=0
Problem: Left shift is incorrect with vartabstop and shiftwidth=0 Solution: make tabstop_at() function aware of shift direction (Gary Johnson) The problem was that with 'vartabstop' set and 'shiftwidth' equal 0, left shifts using << were shifting the line to the wrong column. The tabstop to the right of the first character in the line was being used as the shift amount instead of the tabstop to the left of that first character. The reason was that the tabstop_at() function always returned the value of the tabstop to the right of the given column and was not accounting for the direction of the shift. The solution was to make tabstop_at() aware of the direction of the shift and to choose the tabtop accordingly. A test was added to check this behavior and make sure it doesn't regress. While at it, also fix a few indentation/alignment issues. fixes: #14864 closes: #14887 Signed-off-by: Gary Johnson <garyjohn@spocom.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
e299591498
commit
88d4f255b7
16
src/ops.c
16
src/ops.c
@@ -231,7 +231,7 @@ shift_line(
|
||||
{
|
||||
vimlong_T count;
|
||||
int i, j;
|
||||
int sw_val = trim_to_int(get_sw_value_indent(curbuf));
|
||||
int sw_val = trim_to_int(get_sw_value_indent(curbuf, left));
|
||||
|
||||
count = get_indent(); // get current indent
|
||||
|
||||
@@ -283,7 +283,7 @@ shift_block(oparg_T *oap, int amount)
|
||||
char_u *newp, *oldp;
|
||||
size_t newlen, oldlen;
|
||||
int oldcol = curwin->w_cursor.col;
|
||||
int sw_val = (int)get_sw_value_indent(curbuf);
|
||||
int sw_val = (int)get_sw_value_indent(curbuf, left);
|
||||
int ts_val = (int)curbuf->b_p_ts;
|
||||
struct block_def bd;
|
||||
int incr;
|
||||
@@ -1258,8 +1258,8 @@ op_replace(oparg_T *oap, int c)
|
||||
replace_character(c);
|
||||
else
|
||||
PBYTE(curwin->w_cursor, c);
|
||||
if (inc(&curwin->w_cursor) == -1)
|
||||
break;
|
||||
if (inc(&curwin->w_cursor) == -1)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2523,11 +2523,11 @@ op_addsub(
|
||||
int change_cnt = 0;
|
||||
linenr_T amount = Prenum1;
|
||||
|
||||
// do_addsub() might trigger re-evaluation of 'foldexpr' halfway, when the
|
||||
// buffer is not completely updated yet. Postpone updating folds until before
|
||||
// the call to changed_lines().
|
||||
// do_addsub() might trigger re-evaluation of 'foldexpr' halfway, when the
|
||||
// buffer is not completely updated yet. Postpone updating folds until before
|
||||
// the call to changed_lines().
|
||||
#ifdef FEAT_FOLDING
|
||||
disable_fold_update++;
|
||||
disable_fold_update++;
|
||||
#endif
|
||||
|
||||
if (!VIsual_active)
|
||||
|
Reference in New Issue
Block a user