Mercurial > vim
comparison src/ex_cmds.c @ 15367:273649cad196 v8.1.0691
patch 8.1.0691: text properties are not adjusted for :substitute
commit https://github.com/vim/vim/commit/4164bb204e97a2ff3d6c43cba779bdff9e853892
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Jan 4 23:09:49 2019 +0100
patch 8.1.0691: text properties are not adjusted for :substitute
Problem: Text properties are not adjusted for :substitute.
Solution: Adjust text properties as well as possible.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 04 Jan 2019 23:15:04 +0100 |
parents | a6330a49e036 |
children | 55ccc2d353bd |
comparison
equal
deleted
inserted
replaced
15366:537ee1380f26 | 15367:273649cad196 |
---|---|
5626 /* Need room for: | 5626 /* Need room for: |
5627 * - result so far in new_start (not for first sub in line) | 5627 * - result so far in new_start (not for first sub in line) |
5628 * - original text up to match | 5628 * - original text up to match |
5629 * - length of substituted part | 5629 * - length of substituted part |
5630 * - original text after match | 5630 * - original text after match |
5631 * Adjust text properties here, since we have all information | |
5632 * needed. | |
5631 */ | 5633 */ |
5632 if (nmatch == 1) | 5634 if (nmatch == 1) |
5635 { | |
5633 p1 = sub_firstline; | 5636 p1 = sub_firstline; |
5637 #ifdef FEAT_TEXT_PROP | |
5638 if (curbuf->b_has_textprop) | |
5639 adjust_prop_columns(lnum, regmatch.startpos[0].col, | |
5640 sublen - 1 - (regmatch.endpos[0].col | |
5641 - regmatch.startpos[0].col)); | |
5642 #endif | |
5643 } | |
5634 else | 5644 else |
5635 { | 5645 { |
5636 p1 = ml_get(sub_firstlnum + nmatch - 1); | 5646 p1 = ml_get(sub_firstlnum + nmatch - 1); |
5637 nmatch_tl += nmatch - 1; | 5647 nmatch_tl += nmatch - 1; |
5638 } | 5648 } |
5730 { | 5740 { |
5731 if (p1[0] == '\\' && p1[1] != NUL) /* remove backslash */ | 5741 if (p1[0] == '\\' && p1[1] != NUL) /* remove backslash */ |
5732 STRMOVE(p1, p1 + 1); | 5742 STRMOVE(p1, p1 + 1); |
5733 else if (*p1 == CAR) | 5743 else if (*p1 == CAR) |
5734 { | 5744 { |
5735 if (u_inssub(lnum) == OK) /* prepare for undo */ | 5745 if (u_inssub(lnum) == OK) // prepare for undo |
5736 { | 5746 { |
5737 *p1 = NUL; /* truncate up to the CR */ | 5747 colnr_T plen = (colnr_T)(p1 - new_start + 1); |
5738 ml_append(lnum - 1, new_start, | 5748 |
5739 (colnr_T)(p1 - new_start + 1), FALSE); | 5749 *p1 = NUL; // truncate up to the CR |
5750 ml_append(lnum - 1, new_start, plen, FALSE); | |
5740 mark_adjust(lnum + 1, (linenr_T)MAXLNUM, 1L, 0L); | 5751 mark_adjust(lnum + 1, (linenr_T)MAXLNUM, 1L, 0L); |
5741 if (subflags.do_ask) | 5752 if (subflags.do_ask) |
5742 appended_lines(lnum - 1, 1L); | 5753 appended_lines(lnum - 1, 1L); |
5743 else | 5754 else |
5744 { | 5755 { |
5745 if (first_line == 0) | 5756 if (first_line == 0) |
5746 first_line = lnum; | 5757 first_line = lnum; |
5747 last_line = lnum + 1; | 5758 last_line = lnum + 1; |
5748 } | 5759 } |
5749 /* All line numbers increase. */ | 5760 #ifdef FEAT_TEXT_PROP |
5761 adjust_props_for_split(lnum, plen, 1); | |
5762 #endif | |
5763 // all line numbers increase | |
5750 ++sub_firstlnum; | 5764 ++sub_firstlnum; |
5751 ++lnum; | 5765 ++lnum; |
5752 ++line2; | 5766 ++line2; |
5753 /* move the cursor to the new line, like Vi */ | 5767 // move the cursor to the new line, like Vi |
5754 ++curwin->w_cursor.lnum; | 5768 ++curwin->w_cursor.lnum; |
5755 /* copy the rest */ | 5769 // copy the rest |
5756 STRMOVE(new_start, p1 + 1); | 5770 STRMOVE(new_start, p1 + 1); |
5757 p1 = new_start - 1; | 5771 p1 = new_start - 1; |
5758 } | 5772 } |
5759 } | 5773 } |
5760 #ifdef FEAT_MBYTE | 5774 #ifdef FEAT_MBYTE |