mirror of
https://github.com/neovim/neovim
synced 2025-07-15 16:51:49 +00:00
vim-patch:8.2.0109: corrupted text properties when expanding spaces
Problem: Corrupted text properties when expanding spaces. Solution: Reallocate the line. (Nobuhiro Takasaki, closes vim/vim#5457)ac15fd8c67
Co-authored-by: Bram Moolenaar <Bram@vim.org> (cherry picked from commit97d9d71bf3
)
This commit is contained in:
committed by
github-actions[bot]
parent
704d33634e
commit
571e54e12c
@ -4420,9 +4420,18 @@ static bool ins_tab(void)
|
||||
int i = cursor->col - fpos.col;
|
||||
if (i > 0) {
|
||||
if (!(State & VREPLACE_FLAG)) {
|
||||
memmove(ptr, ptr + i, (size_t)(curbuf->b_ml.ml_line_len - i
|
||||
- (ptr - curbuf->b_ml.ml_line_ptr)));
|
||||
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 {
|
||||
|
Reference in New Issue
Block a user