diff options
author | VVKot <volodymyr.kot.ua@gmail.com> | 2021-02-13 19:06:37 +0000 |
---|---|---|
committer | VVKot <volodymyr.kot.ua@gmail.com> | 2021-03-28 08:37:01 +0100 |
commit | 6752ac49682d63dfc7960e518ecbd6517c88392d (patch) | |
tree | b0e4a27d32f23ea52f11ae1a6a4f24617f79a5e6 /src/nvim/ops.c | |
parent | b79596eb5e942a299aa021a0f9a3f2db909294da (diff) | |
download | rneovim-6752ac49682d63dfc7960e518ecbd6517c88392d.tar.gz rneovim-6752ac49682d63dfc7960e518ecbd6517c88392d.tar.bz2 rneovim-6752ac49682d63dfc7960e518ecbd6517c88392d.zip |
vim-patch:8.1.0105: all tab stops are the same
Problem: All tab stops are the same.
Solution: Add the variable tabstop feature. (Christian Brabandt,
closes vim/vim#2711)
https://github.com/vim/vim/commit/04958cbaf25eea27eceedaa987adfb354ad5f7fd
Diffstat (limited to 'src/nvim/ops.c')
-rw-r--r-- | src/nvim/ops.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 0ff427c261..ffa3e3d55f 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -333,7 +333,8 @@ static void shift_block(oparg_T *oap, int amount) char_u *newp; const int oldcol = curwin->w_cursor.col; const int p_sw = get_sw_value(curbuf); - const int p_ts = (int)curbuf->b_p_ts; + const long p_ts = curbuf->b_p_ts; + long *p_vts = curbuf->b_p_vts_array; struct block_def bd; int incr; int i = 0, j = 0; @@ -383,12 +384,11 @@ static void shift_block(oparg_T *oap, int amount) } /* OK, now total=all the VWS reqd, and textstart points at the 1st * non-ws char in the block. */ - if (!curbuf->b_p_et) - i = ((ws_vcol % p_ts) + total) / p_ts; /* number of tabs */ - if (i) - j = ((ws_vcol % p_ts) + total) % p_ts; /* number of spp */ - else + if (!curbuf->b_p_et) { + tabstop_fromto(ws_vcol, ws_vcol + total, p_ts, p_vts, &i, &j); + } else { j = total; + } // if we're splitting a TAB, allow for it int col_pre = bd.pre_whitesp_c - (bd.startspaces != 0); @@ -3061,14 +3061,17 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) if (gchar_cursor() == TAB) { /* Don't need to insert spaces when "p" on the last position of a * tab or "P" on the first position. */ + int viscol = getviscol(); if (dir == FORWARD - ? (int)curwin->w_cursor.coladd < curbuf->b_p_ts - 1 - : curwin->w_cursor.coladd > 0) - coladvance_force(getviscol()); - else + ? tabstop_padding(viscol, curbuf->b_p_ts, curbuf->b_p_vts_array) != 1 + : curwin->w_cursor.coladd > 0) { + coladvance_force(viscol); + } else { curwin->w_cursor.coladd = 0; - } else if (curwin->w_cursor.coladd > 0 || gchar_cursor() == NUL) + } + } else if (curwin->w_cursor.coladd > 0 || gchar_cursor() == NUL) { coladvance_force(getviscol() + (dir == FORWARD)); + } } lnum = curwin->w_cursor.lnum; |