Mercurial > vim
diff src/textprop.c @ 29748:7e2321707fea v9.0.0214
patch 9.0.0214: splitting a line may duplicate virtual text
Commit: https://github.com/vim/vim/commit/d8d4cfcb393123fa19640be0806091d47935407f
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Aug 15 15:55:10 2022 +0100
patch 9.0.0214: splitting a line may duplicate virtual text
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 15 Aug 2022 17:00:06 +0200 |
parents | 89e1d67814a9 |
children | d08aa1bfe319 |
line wrap: on
line diff
--- 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) {