diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-10-25 22:13:29 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-10-25 22:13:29 +0200 |
commit | 1fd30d7bae1b3e57f008c052d765a3ec73d58114 (patch) | |
tree | 9b2bd3dbfba4406d89eb6e89dad0cdd2dae50f4a /src/ex_cmds.c | |
parent | 7aee6876eb4a66cc9d475e30bb58c060e7d4e90e (diff) |
patch 8.1.2216: text property in wrong place after :substitutev8.1.2216
Problem: Text property in wrong place after :substitute.
Solution: Pass the new column instead of the old one. (Christian Brabandt,
closes #4427)
Diffstat (limited to 'src/ex_cmds.c')
-rw-r--r-- | src/ex_cmds.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c index e472c8a6fc..7153606282 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -3856,6 +3856,7 @@ do_sub(exarg_T *eap) colnr_T matchcol; colnr_T prev_matchcol = MAXCOL; char_u *new_end, *new_start = NULL; + colnr_T total_added = 0; unsigned new_start_len = 0; char_u *p1; int did_sub = FALSE; @@ -4279,13 +4280,18 @@ do_sub(exarg_T *eap) #ifdef FEAT_TEXT_PROP if (curbuf->b_has_textprop) { + int bytes_added = sublen - 1 - (regmatch.endpos[0].col + - regmatch.startpos[0].col); + // When text properties are changed, need to save for // undo first, unless done already. - if (adjust_prop_columns(lnum, regmatch.startpos[0].col, - sublen - 1 - (regmatch.endpos[0].col - - regmatch.startpos[0].col), - apc_flags)) + if (adjust_prop_columns(lnum, + total_added + regmatch.startpos[0].col, + bytes_added, apc_flags)) apc_flags &= ~APC_SAVE_FOR_UNDO; + // Offset for column byte number of the text property + // in the resulting buffer afterwards. + total_added += bytes_added; } #endif } |