diff options
author | LemonBoy <thatlemon@gmail.com> | 2022-05-12 18:45:18 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-05-12 18:45:18 +0100 |
commit | d0b1a09f44654bb5e29b09de1311845200f17d90 (patch) | |
tree | 49850d04a1a61b64980fa68e42c1156407cc22ba /src/change.c | |
parent | 39c46b43780ad00ea27a93d92aadd44753d4c3ea (diff) |
patch 8.2.4944: text properties are wrong after "cc"v8.2.4944
Problem: Text properties are wrong after "cc". (Axel Forsman)
Solution: Pass the deleted byte count to inserted_bytes(). (closes #10412,
closes #7737, closes #5763)
Diffstat (limited to 'src/change.c')
-rw-r--r-- | src/change.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/change.c b/src/change.c index 1facaededa..8ba0a54f4a 100644 --- a/src/change.c +++ b/src/change.c @@ -2349,11 +2349,15 @@ truncate_line(int fixpos) char_u *newp; linenr_T lnum = curwin->w_cursor.lnum; colnr_T col = curwin->w_cursor.col; + char_u *old_line; + int deleted; + old_line = ml_get(lnum); if (col == 0) newp = vim_strsave((char_u *)""); else - newp = vim_strnsave(ml_get(lnum), col); + newp = vim_strnsave(old_line, col); + deleted = (int)STRLEN(old_line) - col; if (newp == NULL) return FAIL; @@ -2361,7 +2365,7 @@ truncate_line(int fixpos) ml_replace(lnum, newp, FALSE); // mark the buffer as changed and prepare for displaying - changed_bytes(lnum, curwin->w_cursor.col); + inserted_bytes(lnum, curwin->w_cursor.col, -deleted); // If "fixpos" is TRUE we don't want to end up positioned at the NUL. if (fixpos && curwin->w_cursor.col > 0) |