]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0221: lines following virt text (that fills the window) might be truncated v9.1.0221
authorDylan Thacker-Smith <dylan.ah.smith@gmail.com>
Thu, 28 Mar 2024 10:40:41 +0000 (11:40 +0100)
committerChristian Brabandt <cb@256bit.org>
Thu, 28 Mar 2024 10:51:05 +0000 (11:51 +0100)
Problem:  The if branch to set `text_prop_follows` was both checking if
          it was at the end of the buffer text line or if it was at the
          end of the screen line, but the former being true skipped
          a guard condition in the latter to only consider 'below'
          virtual text to follow. `text_prop_follows` being improperly
          set caused it to skip a conditional block to break at the end
          as well as one to move `ptr` to the end of the text line,
          while repeated for each following line of the window.
Solution: Move the check for whether 'below' virtual text should follow
          so it is also used when at the end of the buffer text line.
          (Dylan Thacker-Smith)

fixes: #12213
related: #14307

Signed-off-by: Dylan Thacker-Smith <dylan.ah.smith@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/drawline.c
src/testdir/dumps/Test_props_with_text_truncated_just_before_after_1.dump [new file with mode: 0644]
src/testdir/dumps/Test_props_with_text_truncated_just_before_after_2.dump [new file with mode: 0644]
src/testdir/test_textprop.vim
src/version.c

index 103760fa18921466cdb6200c803cdcba5d0d7b8e..8abe8bfa5f5552b34c27e2fd8a35bc9ef4c1f148 100644 (file)
@@ -2323,15 +2323,17 @@ win_line(
                else if (text_prop_next < text_prop_count
                           && text_props[text_prop_next].tp_col == MAXCOL
                           && ((*ptr != NUL && ptr[mb_ptr2len(ptr)] == NUL)
-                              || (!wp->w_p_wrap
-                                      && wlv.col == wp->w_width - 1
-                                      && (text_props[text_prop_next].tp_flags
-                                                     & TP_FLAG_ALIGN_BELOW))))
+                              || (!wp->w_p_wrap && wlv.col == wp->w_width - 1)))
+               {
                    // When at last-but-one character and a text property
                    // follows after it, we may need to flush the line after
                    // displaying that character.
                    // Or when not wrapping and at the rightmost column.
-                   text_prop_follows = TRUE;
+                   int only_below_follows = !wp->w_p_wrap && wlv.col == wp->w_width - 1;
+                   if (!only_below_follows
+                           || (text_props[text_prop_next].tp_flags & TP_FLAG_ALIGN_BELOW))
+                       text_prop_follows = TRUE;
+               }
            }
 
            if (wlv.start_extra_for_textprop)
diff --git a/src/testdir/dumps/Test_props_with_text_truncated_just_before_after_1.dump b/src/testdir/dumps/Test_props_with_text_truncated_just_before_after_1.dump
new file mode 100644 (file)
index 0000000..f46f47e
--- /dev/null
@@ -0,0 +1,8 @@
+|h+0&#ffffff0|e|r|e| |i|s| |t|e|x|t| |l|o|n|g| |e|n|o|u|g|h| |t|o| |f|i|l@1| |t|h|e| |r|o|>+0#4040ff13&
+|s+0#0000000&|e|c|o|n|d| |l|i|n>e| @28
+|~+0#4040ff13&| @38
+|~| @38
+|~| @38
+|~| @38
+|~| @38
+| +0#0000000&@21|2|,|1@1| @9|A|l@1| 
diff --git a/src/testdir/dumps/Test_props_with_text_truncated_just_before_after_2.dump b/src/testdir/dumps/Test_props_with_text_truncated_just_before_after_2.dump
new file mode 100644 (file)
index 0000000..3434669
--- /dev/null
@@ -0,0 +1,8 @@
+|h+0&#ffffff0|e|r|e| |i|s| |t|e|x|t| |l|o|n|g| |e|n|o|u|g|h| |t|o| |f|i|l@1| |t|h|e| |r|o|>+0#4040ff13&
+|b+0#ffffff16#ff404010|e|l|o|w| |t|e|x|t| +0#0000000#ffffff0@29
+|s|e|c|o|n|d| |l|i|n>e| @28
+|~+0#4040ff13&| @38
+|~| @38
+|~| @38
+|~| @38
+| +0#0000000&@21|2|,|1@1| @9|A|l@1| 
index 63cc533693ba1545512d51c29e35b398173ccfd7..22c7e4651bf481ebbf99b807e1cc8e12300cbded 100644 (file)
@@ -3068,6 +3068,40 @@ func Test_props_with_text_after_below_trunc()
   call StopVimInTerminal(buf)
 endfunc
 
+func Test_props_with_text_truncated_just_before_after()
+  CheckRunVimInTerminal
+
+  let lines =<< trim END
+      vim9script
+      set showbreak=+++
+      set list listchars=extends:>
+      set nowrap
+
+      setline(1, [
+        'here is text long enough to fill the row',
+        'second line',
+      ])
+
+      prop_type_add("test", {"highlight": "Error"})
+      prop_add(1, 0, {type: "test", text: "after text", text_padding_left: 1})
+      def g:AddPropBelow()
+        prop_add(1, 0, {type: "test", text_align: "below", text: "below text"})
+      enddef
+      def g:AddPropRight()
+        prop_add(1, 0, {type: "test", text_align: "right", text: "right text"})
+      enddef
+      normal G$
+  END
+  call writefile(lines, 'XscriptPropsWithTextTruncatedJustBeforeAfter', 'D')
+  let buf = RunVimInTerminal('-S XscriptPropsWithTextTruncatedJustBeforeAfter', #{rows: 8, cols: 40})
+  call VerifyScreenDump(buf, 'Test_props_with_text_truncated_just_before_after_1', {})
+
+  call term_sendkeys(buf, ":call AddPropBelow()\<CR>")
+  call VerifyScreenDump(buf, 'Test_props_with_text_truncated_just_before_after_2', {})
+
+  call StopVimInTerminal(buf)
+endfunc
+
 func Test_prop_with_text_below_after_empty()
   CheckRunVimInTerminal
 
index 20618a6910be8d876d832ba8f06e3592e7ba5faa..f853a6968acdb873a1ee70311a6709fe13310689 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    221,
 /**/
     220,
 /**/