summaryrefslogtreecommitdiff
path: root/src/textprop.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-08-01 22:18:50 +0100
committerBram Moolenaar <Bram@vim.org>2022-08-01 22:18:50 +0100
commite175dc6911948bcd0c854876b534fee62fb95b9f (patch)
tree67b74045048bee4fbcaa4fa4340b1fccba7084a3 /src/textprop.c
parent09ff4b54fb86a64390ba9c609853c6410ea6197c (diff)
downloadvim-git-e175dc6911948bcd0c854876b534fee62fb95b9f.tar.gz
patch 9.0.0133: virtual text after line moves to joined linev9.0.0133
Problem: Virtual text after line moves to joined line. (Yegappan Lakshmanan) Solution: When joining lines only keep virtual text after the last line.
Diffstat (limited to 'src/textprop.c')
-rw-r--r--src/textprop.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/textprop.c b/src/textprop.c
index 6fefc6d24..9a9544c50 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -600,7 +600,7 @@ get_text_props(buf_T *buf, linenr_T lnum, char_u **props, int will_change)
* be considered.
*/
int
-count_props(linenr_T lnum, int only_starting)
+count_props(linenr_T lnum, int only_starting, int last_line)
{
char_u *props;
int proplen = get_text_props(curbuf, lnum, &props, 0);
@@ -608,13 +608,16 @@ count_props(linenr_T lnum, int only_starting)
int i;
textprop_T prop;
- if (only_starting)
- for (i = 0; i < proplen; ++i)
- {
- mch_memmove(&prop, props + i * sizeof(prop), sizeof(prop));
- if (prop.tp_flags & TP_FLAG_CONT_PREV)
- --result;
- }
+ for (i = 0; i < proplen; ++i)
+ {
+ mch_memmove(&prop, props + i * sizeof(prop), sizeof(prop));
+ // A prop is droppend when in the first line and it continues from the
+ // previous line, or when not in the last line and it is virtual text
+ // after the line.
+ if ((only_starting && (prop.tp_flags & TP_FLAG_CONT_PREV))
+ || (!last_line && prop.tp_col == MAXCOL))
+ --result;
+ }
return result;
}
@@ -2024,7 +2027,7 @@ prepend_joined_props(
int propcount,
int *props_remaining,
linenr_T lnum,
- int add_all,
+ int last_line,
long col,
int removed)
{
@@ -2038,12 +2041,14 @@ prepend_joined_props(
int end;
mch_memmove(&prop, props + i * sizeof(prop), sizeof(prop));
+ if (prop.tp_col == MAXCOL && !last_line)
+ continue; // drop property with text after the line
end = !(prop.tp_flags & TP_FLAG_CONT_NEXT);
adjust_prop(&prop, 0, -removed, 0); // Remove leading spaces
adjust_prop(&prop, -1, col, 0); // Make line start at its final column
- if (add_all || end)
+ if (last_line || end)
mch_memmove(new_props + --(*props_remaining) * sizeof(prop),
&prop, sizeof(prop));
else