0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.1.1359: text property wrong after :substitute with backslash

Problem:    Text property wrong after :substitute with backslash.
Solution:   Adjust text property columns when removing backslashes.
            (closes #4397)
This commit is contained in:
Bram Moolenaar
2019-05-19 22:53:40 +02:00
parent 386b43e594
commit f3333b02f3
10 changed files with 72 additions and 17 deletions

View File

@@ -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