aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-06-02 15:37:11 +0800
committerGitHub <noreply@github.com>2024-06-02 15:37:11 +0800
commit24cb9ba6d32918beaba5a2109f5f8d8009cd097d (patch)
tree2e4d35fd4388b56389659e64f95da2cc8ed994a2 /src
parent05435a915a8446a8c2d824551fbea2dc1d7b5e98 (diff)
parent56337310efc765a760b7a1ca0040c7c6ce23574e (diff)
downloadrneovim-24cb9ba6d32918beaba5a2109f5f8d8009cd097d.tar.gz
rneovim-24cb9ba6d32918beaba5a2109f5f8d8009cd097d.tar.bz2
rneovim-24cb9ba6d32918beaba5a2109f5f8d8009cd097d.zip
Merge pull request #29136 from zeertzjq/vim-8.2.0083
vim-patch:8.2.{0083,0109}
Diffstat (limited to 'src')
-rw-r--r--src/nvim/edit.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 595b4da589..f6e2dbfa4e 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -4421,18 +4421,30 @@ 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)) {
+ char *newp = xmalloc((size_t)(curbuf->b_ml.ml_line_len - i));
+ ptrdiff_t col = ptr - curbuf->b_ml.ml_line_ptr;
+ if (col > 0) {
+ memmove(newp, ptr - col, (size_t)col);
+ }
+ memmove(newp + col, ptr + i, (size_t)(curbuf->b_ml.ml_line_len - col - i));
+ if (curbuf->b_ml.ml_flags & (ML_LINE_DIRTY | ML_ALLOCATED)) {
+ xfree(curbuf->b_ml.ml_line_ptr);
+ }
+ curbuf->b_ml.ml_line_ptr = newp;
+ curbuf->b_ml.ml_line_len -= i;
+ curbuf->b_ml.ml_flags = (curbuf->b_ml.ml_flags | ML_LINE_DIRTY) & ~ML_EMPTY;
+ 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;