comparison src/ex_cmds.c @ 16714:ba592f30c082 v8.1.1359

patch 8.1.1359: text property wrong after :substitute with backslash commit https://github.com/vim/vim/commit/f3333b02f34526da46cdae608f7e2d869bb8c654 Author: Bram Moolenaar <Bram@vim.org> Date: Sun May 19 22:53:40 2019 +0200 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)
author Bram Moolenaar <Bram@vim.org>
date Sun, 19 May 2019 23:00:05 +0200
parents 77bcb5055fec
children 5a541d459ef7
comparison
equal deleted inserted replaced
16713:ba3f15a7e5c9 16714:ba592f30c082
5187 long nmatch_tl = 0; /* nr of lines matched below lnum */ 5187 long nmatch_tl = 0; /* nr of lines matched below lnum */
5188 int do_again; /* do it again after joining lines */ 5188 int do_again; /* do it again after joining lines */
5189 int skip_match = FALSE; 5189 int skip_match = FALSE;
5190 linenr_T sub_firstlnum; /* nr of first sub line */ 5190 linenr_T sub_firstlnum; /* nr of first sub line */
5191 #ifdef FEAT_TEXT_PROP 5191 #ifdef FEAT_TEXT_PROP
5192 int save_for_undo = TRUE; 5192 int apc_flags = APC_SAVE_FOR_UNDO | APC_SUBSTITUTE;
5193 #endif 5193 #endif
5194 5194
5195 /* 5195 /*
5196 * The new text is build up step by step, to avoid too much 5196 * The new text is build up step by step, to avoid too much
5197 * copying. There are these pieces: 5197 * copying. There are these pieces:
5610 { 5610 {
5611 // When text properties are changed, need to save for 5611 // When text properties are changed, need to save for
5612 // undo first, unless done already. 5612 // undo first, unless done already.
5613 if (adjust_prop_columns(lnum, regmatch.startpos[0].col, 5613 if (adjust_prop_columns(lnum, regmatch.startpos[0].col,
5614 sublen - 1 - (regmatch.endpos[0].col 5614 sublen - 1 - (regmatch.endpos[0].col
5615 - regmatch.startpos[0].col), save_for_undo)) 5615 - regmatch.startpos[0].col),
5616 save_for_undo = FALSE; 5616 apc_flags))
5617 apc_flags &= ~APC_SAVE_FOR_UNDO;
5617 } 5618 }
5618 #endif 5619 #endif
5619 } 5620 }
5620 else 5621 else
5621 { 5622 {
5713 * That is Vi compatible. 5714 * That is Vi compatible.
5714 */ 5715 */
5715 for (p1 = new_end; *p1; ++p1) 5716 for (p1 = new_end; *p1; ++p1)
5716 { 5717 {
5717 if (p1[0] == '\\' && p1[1] != NUL) /* remove backslash */ 5718 if (p1[0] == '\\' && p1[1] != NUL) /* remove backslash */
5719 {
5718 STRMOVE(p1, p1 + 1); 5720 STRMOVE(p1, p1 + 1);
5721 #ifdef FEAT_TEXT_PROP
5722 if (curbuf->b_has_textprop)
5723 {
5724 // When text properties are changed, need to save
5725 // for undo first, unless done already.
5726 if (adjust_prop_columns(lnum,
5727 (colnr_T)(p1 - new_start), -1,
5728 apc_flags))
5729 apc_flags &= ~APC_SAVE_FOR_UNDO;
5730 }
5731 #endif
5732 }
5719 else if (*p1 == CAR) 5733 else if (*p1 == CAR)
5720 { 5734 {
5721 if (u_inssub(lnum) == OK) // prepare for undo 5735 if (u_inssub(lnum) == OK) // prepare for undo
5722 { 5736 {
5723 colnr_T plen = (colnr_T)(p1 - new_start + 1); 5737 colnr_T plen = (colnr_T)(p1 - new_start + 1);