summaryrefslogtreecommitdiff
path: root/src/ex_cmds.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-01-04 23:09:49 +0100
committerBram Moolenaar <Bram@vim.org>2019-01-04 23:09:49 +0100
commit4164bb204e97a2ff3d6c43cba779bdff9e853892 (patch)
tree133f8b60bbd378847ac6832630b3b9a238774214 /src/ex_cmds.c
parent21b5038e02306ce2fd438249055eed372befe51f (diff)
downloadvim-git-4164bb204e97a2ff3d6c43cba779bdff9e853892.tar.gz
patch 8.1.0691: text properties are not adjusted for :substitutev8.1.0691
Problem: Text properties are not adjusted for :substitute. Solution: Adjust text properties as well as possible.
Diffstat (limited to 'src/ex_cmds.c')
-rw-r--r--src/ex_cmds.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index 52c0e5bed..9990bca21 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -5628,9 +5628,19 @@ do_sub(exarg_T *eap)
* - original text up to match
* - length of substituted part
* - original text after match
+ * Adjust text properties here, since we have all information
+ * needed.
*/
if (nmatch == 1)
+ {
p1 = sub_firstline;
+#ifdef FEAT_TEXT_PROP
+ if (curbuf->b_has_textprop)
+ adjust_prop_columns(lnum, regmatch.startpos[0].col,
+ sublen - 1 - (regmatch.endpos[0].col
+ - regmatch.startpos[0].col));
+#endif
+ }
else
{
p1 = ml_get(sub_firstlnum + nmatch - 1);
@@ -5732,11 +5742,12 @@ do_sub(exarg_T *eap)
STRMOVE(p1, p1 + 1);
else if (*p1 == CAR)
{
- if (u_inssub(lnum) == OK) /* prepare for undo */
+ if (u_inssub(lnum) == OK) // prepare for undo
{
- *p1 = NUL; /* truncate up to the CR */
- ml_append(lnum - 1, new_start,
- (colnr_T)(p1 - new_start + 1), FALSE);
+ colnr_T plen = (colnr_T)(p1 - new_start + 1);
+
+ *p1 = NUL; // truncate up to the CR
+ ml_append(lnum - 1, new_start, plen, FALSE);
mark_adjust(lnum + 1, (linenr_T)MAXLNUM, 1L, 0L);
if (subflags.do_ask)
appended_lines(lnum - 1, 1L);
@@ -5746,13 +5757,16 @@ do_sub(exarg_T *eap)
first_line = lnum;
last_line = lnum + 1;
}
- /* All line numbers increase. */
+#ifdef FEAT_TEXT_PROP
+ adjust_props_for_split(lnum, plen, 1);
+#endif
+ // all line numbers increase
++sub_firstlnum;
++lnum;
++line2;
- /* move the cursor to the new line, like Vi */
+ // move the cursor to the new line, like Vi
++curwin->w_cursor.lnum;
- /* copy the rest */
+ // copy the rest
STRMOVE(new_start, p1 + 1);
p1 = new_start - 1;
}