patch 9.0.1770: lines disappear when modifying chars before virt text
Commit:
https://github.com/vim/vim/commit/a6ab5e69d3f14da8036a3018e8e93c635803ee8b
Author: Ibby <[email protected]>
Date: Sun Aug 20 20:24:18 2023 +0200
patch 9.0.1770: lines disappear when modifying chars before virt text
Problem: lines disappear when modifying chars before virt text
Solution: take virtual text property length into account
closes: #12558
closes: #12244
Signed-off-by: Christian Brabandt <[email protected]>
Co-authored-by: Ibby <[email protected]>
diff --git a/src/charset.c b/src/charset.c
index 7ffd8d8a7..14373c1c3 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -808,16 +808,14 @@ win_linetabsize_cts(chartabsize_T *cts, colnr_T len)
MB_PTR_ADV(cts->cts_ptr))
cts->cts_vcol += win_lbr_chartabsize(cts, NULL);
#ifdef FEAT_PROP_POPUP
- // check for a virtual text on an empty line
- if (cts->cts_has_prop_with_text && *cts->cts_ptr == NUL
- && cts->cts_ptr == cts->cts_line)
+ // check for a virtual text at the end of a line or on an empty line
+ if (cts->cts_has_prop_with_text && *cts->cts_ptr == NUL)
{
(void)win_lbr_chartabsize(cts, NULL);
cts->cts_vcol += cts->cts_cur_text_width;
-
// when properties are above or below the empty line must also be
// counted
- if (cts->cts_prop_lines > 0)
+ if (cts->cts_ptr == cts->cts_line && cts->cts_prop_lines > 0)
++cts->cts_vcol;
}
#endif
@@ -1190,7 +1188,7 @@ win_lbr_chartabsize(
|| (tp->tp_col == MAXCOL
&& ((tp->tp_flags & TP_FLAG_ALIGN_ABOVE)
? col == 0
- : (s[0] == NUL || s[charlen] == NUL)
+ : s[0] == NUL
&& cts->cts_with_trailing)))
&& -tp->tp_id - 1 < gap->ga_len)
{
diff --git a/src/testdir/dumps/Test_modify_text_before_prop_1.dump
b/src/testdir/dumps/Test_modify_text_before_prop_1.dump
new file mode 100644
index 000000000..87305d434
--- /dev/null
+++ b/src/testdir/dumps/Test_modify_text_before_prop_1.dump
@@ -0,0 +1,5 @@
+| +0#af5f00255#ffffff0@1|1| >t+0#0000000&|e|s|t|_|w|o|r|d|s|a+0&#ffd7ff255@45
+| +0#af5f00255#ffffff0@3|a+0#0000000#ffd7ff255@18| +0&#ffffff0@36
+| +0#af5f00255&@3|a+0#4040ff13&@54|…
+| +0#af5f00255&@1|2| |s+0#0000000&|e|c|o|n|d| |l|i|n|e| @44
+@42|1|,|1| @10|T|o|p|
diff --git a/src/testdir/dumps/Test_modify_text_before_prop_2.dump
b/src/testdir/dumps/Test_modify_text_before_prop_2.dump
new file mode 100644
index 000000000..9dc87a4f0
--- /dev/null
+++ b/src/testdir/dumps/Test_modify_text_before_prop_2.dump
@@ -0,0 +1,5 @@
+| +0#af5f00255#ffffff0@1|1| >a+0#0000000&|s|t|_|w|o|r|d|s|a+0&#ffd7ff255@46
+| +0#af5f00255#ffffff0@3|a+0#0000000#ffd7ff255@17| +0&#ffffff0@37
+| +0#af5f00255&@3|a+0#4040ff13&@54|…
+| +0#af5f00255&@1|2| |s+0#0000000&|e|c|o|n|d| |l|i|n|e| @44
+@42|1|,|1| @10|T|o|p|
diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim
index 9cf46d7d9..dcb408c10 100644
--- a/src/testdir/test_textprop.vim
+++ b/src/testdir/test_textprop.vim
@@ -3979,6 +3979,28 @@ func Test_error_after_using_negative_id()
call StopVimInTerminal(buf)
endfunc
+func Test_modify_text_before_prop()
+ CheckRunVimInTerminal
+
+ let lines =<< trim END
+ vim9script
+ setline(1, ['test_words', 'second line', 'third line', 'fourth line'])
+ set number
+ prop_type_add('text', {highlight: 'DiffChange'})
+ prop_type_add('below', {highlight: 'NonText'})
+ prop_add(1, 11, {type: 'text', text: repeat('a', 65)})
+ prop_add(1, 0, {type: 'below', text: repeat('a', 65), text_align:
'below'})
+ END
+ call writefile(lines, 'XtextPropModifyBefore', 'D')
+ let buf = RunVimInTerminal('-S XtextPropModifyBefore', #{rows: 5, cols: 60})
+ call VerifyScreenDump(buf, 'Test_modify_text_before_prop_1', {})
+
+ call term_sendkeys(buf, "xxia\<Esc>")
+ call VerifyScreenDump(buf, 'Test_modify_text_before_prop_2', {})
+
+ call StopVimInTerminal(buf)
+endfunc
+
func Test_overlong_textprop_above_crash()
CheckRunVimInTerminal
diff --git a/src/version.c b/src/version.c
index e81dd7184..83a007553 100644
--- a/src/version.c
+++ b/src/version.c
@@ -695,6 +695,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1770,
/**/
1769,
/**/
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/E1qXnQ7-00AsKd-Fk%40256bit.org.