diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-01-09 21:35:48 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-01-09 21:35:48 +0100 |
commit | ac15fd8c6761763c8feedef1a2fbd8309f0a823c (patch) | |
tree | 894e9e51f2f0a13c10cd3ac540db63d6f64beecd /src/edit.c | |
parent | bf0acff012c2f75563c20241f1a5478534fe2c7a (diff) |
patch 8.2.0109: corrupted text properties when expanding spacesv8.2.0109
Problem: Corrupted text properties when expanding spaces.
Solution: Reallocate the line. (Nobuhiro Takasaki, closes #5457)
Diffstat (limited to 'src/edit.c')
-rw-r--r-- | src/edit.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/edit.c b/src/edit.c index d2e45dd2f0..8160fe5693 100644 --- a/src/edit.c +++ b/src/edit.c @@ -5604,9 +5604,25 @@ ins_tab(void) #ifdef FEAT_PROP_POPUP if (!(State & VREPLACE_FLAG)) { - mch_memmove(ptr, ptr + i, curbuf->b_ml.ml_line_len - i - - (ptr - curbuf->b_ml.ml_line_ptr)); + char_u *newp; + int col; + + newp = alloc(curbuf->b_ml.ml_line_len - i); + if (newp == NULL) + return FALSE; + + col = ptr - curbuf->b_ml.ml_line_ptr; + if (col > 0) + mch_memmove(newp, ptr - col, col); + mch_memmove(newp + col, ptr + i, + curbuf->b_ml.ml_line_len - col - i); + + if (curbuf->b_ml.ml_flags & ML_LINE_DIRTY) + vim_free(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; } else #endif |