1
0
forked from aniani/vim

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)
This commit is contained in:
Bram Moolenaar
2022-08-15 15:55:10 +01:00
parent 249e1b903a
commit d8d4cfcb39
12 changed files with 58 additions and 11 deletions

View File

@@ -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)
{