commit 4374ec83cd49d148fc788bdb43f49d4b0365cf9f
parent 05435a915a8446a8c2d824551fbea2dc1d7b5e98
Author: zeertzjq <zeertzjq@outlook.com>
Date: Sun, 2 Jun 2024 14:58:12 +0800
vim-patch:8.2.0083: text properties wrong when tabs and spaces are exchanged
Problem: Text properties wrong when tabs and spaces are exchanged.
Solution: Take text properties into account. (Nobuhiro Takasaki,
closes vim/vim#5427)
https://github.com/vim/vim/commit/5cb0b93d52fa5c12ca50a18509947ee6459bb7a8
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat:
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
@@ -4421,18 +4421,21 @@ static bool ins_tab(void)
// Delete following spaces.
int i = cursor->col - fpos.col;
if (i > 0) {
- STRMOVE(ptr, ptr + i);
+ if (!(State & VREPLACE_FLAG)) {
+ memmove(ptr, ptr + i, (size_t)(curbuf->b_ml.ml_line_len - i
+ - (ptr - curbuf->b_ml.ml_line_ptr)));
+ curbuf->b_ml.ml_line_len -= i;
+ inserted_bytes(fpos.lnum, change_col,
+ cursor->col - change_col, fpos.col - change_col);
+ } else {
+ STRMOVE(ptr, ptr + i);
+ }
// correct replace stack.
if ((State & REPLACE_FLAG) && !(State & VREPLACE_FLAG)) {
for (temp = i; --temp >= 0;) {
replace_join(repl_off);
}
}
- if (!(State & VREPLACE_FLAG)) {
- curbuf->b_ml.ml_line_len -= i;
- inserted_bytes(fpos.lnum, change_col,
- cursor->col - change_col, fpos.col - change_col);
- }
}
cursor->col -= i;