diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-08-15 15:55:10 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-08-15 15:55:10 +0100 |
commit | d8d4cfcb393123fa19640be0806091d47935407f (patch) | |
tree | 2cf43a5cc1e08d69c07707565319ffae954d1ea0 /src/textprop.c | |
parent | 249e1b903a9c0460d618f6dcc59aeb8c03b24b20 (diff) |
patch 9.0.0214: splitting a line may duplicate virtual textv9.0.0214
Problem: Splitting a line may duplicate virtual text. (Ben Jackson)
Solution: Don't duplicate a text property with virtual text. Make
auto-indenting work better. (closes #10919)
Diffstat (limited to 'src/textprop.c')
-rw-r--r-- | src/textprop.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/textprop.c b/src/textprop.c index 1df4840f20..d90d57fac3 100644 --- a/src/textprop.c +++ b/src/textprop.c @@ -1906,6 +1906,7 @@ typedef struct * Only for the current buffer. * "flags" can have: * APC_SUBSTITUTE: Text is replaced, not inserted. + * APC_INDENT: Text is inserted before virtual text prop */ static adjustres_T adjust_prop( @@ -1931,6 +1932,10 @@ adjust_prop( start_incl = (pt != NULL && (pt->pt_flags & PT_FLAG_INS_START_INCL)) || (flags & APC_SUBSTITUTE) || (prop->tp_flags & TP_FLAG_CONT_PREV); + if (prop->tp_id < 0 && (flags & APC_INDENT)) + // when inserting indent just before a character with virtual text + // shift the text property + start_incl = FALSE; end_incl = (pt != NULL && (pt->pt_flags & PT_FLAG_INS_END_INCL)) || (prop->tp_flags & TP_FLAG_CONT_NEXT); // do not drop zero-width props if they later can increase in size @@ -1982,6 +1987,7 @@ adjust_prop( * "flags" can have: * APC_SAVE_FOR_UNDO: Call u_savesub() before making changes to the line. * APC_SUBSTITUTE: Text is replaced, not inserted. + * APC_INDENT: Text is inserted before virtual text prop * Caller is expected to check b_has_textprop and "bytes_added" being non-zero. * Returns TRUE when props were changed. */ @@ -2097,6 +2103,9 @@ adjust_props_for_split( cont_prev = prop.tp_col != MAXCOL && prop.tp_col + !start_incl <= kept; cont_next = prop.tp_col != MAXCOL && skipped <= prop.tp_col + prop.tp_len - !end_incl; + // when a prop has text it is never copied + if (prop.tp_id < 0 && cont_next) + cont_prev = FALSE; if (cont_prev && ga_grow(&prevprop, 1) == OK) { |