aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-06-02 14:58:12 +0800
committerzeertzjq <zeertzjq@outlook.com>2024-06-02 15:00:05 +0800
commit4374ec83cd49d148fc788bdb43f49d4b0365cf9f (patch)
treeea50b0768d9f17b9b027f6cd12434fd8d92502c1
parent05435a915a8446a8c2d824551fbea2dc1d7b5e98 (diff)
downloadrneovim-4374ec83cd49d148fc788bdb43f49d4b0365cf9f.tar.gz
rneovim-4374ec83cd49d148fc788bdb43f49d4b0365cf9f.tar.bz2
rneovim-4374ec83cd49d148fc788bdb43f49d4b0365cf9f.zip
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>
-rw-r--r--src/nvim/edit.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 595b4da589..436d43a4db 100644
--- 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;