diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-05-19 22:53:40 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-05-19 22:53:40 +0200 |
commit | f3333b02f34526da46cdae608f7e2d869bb8c654 (patch) | |
tree | be05ce3393cee6644f8755f59dcdf4b3694dbc33 /src/ex_cmds.c | |
parent | 386b43e59498cc7b52a60f09f74bdb44df99386c (diff) |
patch 8.1.1359: text property wrong after :substitute with backslashv8.1.1359
Problem: Text property wrong after :substitute with backslash.
Solution: Adjust text property columns when removing backslashes.
(closes #4397)
Diffstat (limited to 'src/ex_cmds.c')
-rw-r--r-- | src/ex_cmds.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c index ff86d1cd47..df5dcd01ff 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -5189,7 +5189,7 @@ do_sub(exarg_T *eap) int skip_match = FALSE; linenr_T sub_firstlnum; /* nr of first sub line */ #ifdef FEAT_TEXT_PROP - int save_for_undo = TRUE; + int apc_flags = APC_SAVE_FOR_UNDO | APC_SUBSTITUTE; #endif /* @@ -5612,8 +5612,9 @@ do_sub(exarg_T *eap) // undo first, unless done already. if (adjust_prop_columns(lnum, regmatch.startpos[0].col, sublen - 1 - (regmatch.endpos[0].col - - regmatch.startpos[0].col), save_for_undo)) - save_for_undo = FALSE; + - regmatch.startpos[0].col), + apc_flags)) + apc_flags &= ~APC_SAVE_FOR_UNDO; } #endif } @@ -5715,7 +5716,20 @@ do_sub(exarg_T *eap) for (p1 = new_end; *p1; ++p1) { if (p1[0] == '\\' && p1[1] != NUL) /* remove backslash */ + { STRMOVE(p1, p1 + 1); +#ifdef FEAT_TEXT_PROP + if (curbuf->b_has_textprop) + { + // When text properties are changed, need to save + // for undo first, unless done already. + if (adjust_prop_columns(lnum, + (colnr_T)(p1 - new_start), -1, + apc_flags)) + apc_flags &= ~APC_SAVE_FOR_UNDO; + } +#endif + } else if (*p1 == CAR) { if (u_inssub(lnum) == OK) // prepare for undo |