aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ops.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-06-02 05:47:47 +0800
committerzeertzjq <zeertzjq@outlook.com>2024-06-02 06:06:34 +0800
commit0e49c3ad1a599376d0a5c229f304a06d48c56163 (patch)
treea1910bf0e0137f85e7bad889745582ad4affee65 /src/nvim/ops.c
parent6f87779857f1b7a86da9e53c117b5b678a2a3236 (diff)
downloadrneovim-0e49c3ad1a599376d0a5c229f304a06d48c56163.tar.gz
rneovim-0e49c3ad1a599376d0a5c229f304a06d48c56163.tar.bz2
rneovim-0e49c3ad1a599376d0a5c229f304a06d48c56163.zip
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: vim/vim#14864 closes: vim/vim#14887 https://github.com/vim/vim/commit/88d4f255b7b7a19bb4f6489e0ad0956e47d51fed Co-authored-by: Gary Johnson <garyjohn@spocom.com>
Diffstat (limited to 'src/nvim/ops.c')
-rw-r--r--src/nvim/ops.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 47d302df43..8ae1d70882 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -282,7 +282,7 @@ void op_shift(oparg_T *oap, bool curs_top, int amount)
/// @param call_changed_bytes call changed_bytes()
void shift_line(bool left, bool round, int amount, int call_changed_bytes)
{
- const int sw_val = get_sw_value_indent(curbuf);
+ const int sw_val = get_sw_value_indent(curbuf, left);
int count = get_indent(); // get current indent
@@ -328,7 +328,7 @@ static void shift_block(oparg_T *oap, int amount)
const int oldstate = State;
char *newp;
const int oldcol = curwin->w_cursor.col;
- const int sw_val = get_sw_value_indent(curbuf);
+ const int sw_val = get_sw_value_indent(curbuf, left);
const int ts_val = (int)curbuf->b_p_ts;
struct block_def bd;
int incr;