]> granicus.if.org Git - vim/commitdiff
patch 9.0.0714: with 'nowrap' two virtual text below not displayed correctly v9.0.0714
authorBram Moolenaar <Bram@vim.org>
Mon, 10 Oct 2022 14:40:04 +0000 (15:40 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 10 Oct 2022 14:40:04 +0000 (15:40 +0100)
Problem:    With 'nowrap' two virtual text below not displayed correctly.
Solution:   Set text_prop_follows before continuing.  Correct for number
            column. (closes #11333)

src/drawline.c
src/testdir/dumps/Test_text_below_nowrap_1.dump [new file with mode: 0644]
src/testdir/test_textprop.vim
src/version.c

index e6a785e408e212ec62a81b2c4e41656306f41fda..9aad81b9cccdb87f82d3b610828b5cce03688895 100644 (file)
@@ -578,7 +578,7 @@ textprop_size_after_trunc(
        int     *n_used_ptr)
 {
     int        space = (flags & (TP_FLAG_ALIGN_BELOW | TP_FLAG_ALIGN_ABOVE))
-                                                        ? wp->w_width : added;
+                                      ? wp->w_width - win_col_off(wp) : added;
     int len = (int)STRLEN(text);
     int strsize = 0;
     int n_used;
@@ -634,6 +634,8 @@ text_prop_position(
     int            strsize = vim_strsize(*p_extra);
     int            cells = wrap ? strsize : textprop_size_after_trunc(wp,
                             tp->tp_flags, before, padding, *p_extra, &n_used);
+    int            cont_on_next_line = below && col_with_padding > win_col_off(wp)
+                                                             && !wp->w_p_wrap;
 
     if (wrap || right || above || below || padding > 0 || n_used < *n_extra)
     {
@@ -736,7 +738,11 @@ text_prop_position(
                *n_attr = mb_charlen(*p_extra);
                if (above)
                    *n_attr -= padding + after;
-               *n_attr_skip = before + padding + skip_add;
+
+               // Add "skip_add" when starting a new line or wrapping,
+               // n_attr_skip will then be decremented in the number column.
+               *n_attr_skip = before + padding
+                           + (cont_on_next_line || before > 0 ? skip_add : 0);
            }
        }
     }
@@ -1917,6 +1923,7 @@ win_line(
                                                           -text_prop_id - 1];
                        int         above = (tp->tp_flags
                                                        & TP_FLAG_ALIGN_ABOVE);
+                       int         bail_out = FALSE;
 
                        // reset the ID in the copy to avoid it being used
                        // again
@@ -2003,7 +2010,7 @@ win_line(
                                        break;
                                    }
                                    win_line_start(wp, &wlv, TRUE);
-                                   continue;
+                                   bail_out = TRUE;
                                }
                            }
                        }
@@ -2017,6 +2024,10 @@ win_line(
                            && (wp->w_p_wrap
                                   || (text_props[other_tpi].tp_flags
                               & (TP_FLAG_ALIGN_BELOW | TP_FLAG_ALIGN_RIGHT)));
+
+                       if (bail_out)
+                           // starting a new line for "below"
+                           continue;
                    }
                }
                else if (text_prop_next < text_prop_count
diff --git a/src/testdir/dumps/Test_text_below_nowrap_1.dump b/src/testdir/dumps/Test_text_below_nowrap_1.dump
new file mode 100644 (file)
index 0000000..3325411
--- /dev/null
@@ -0,0 +1,8 @@
+| +0#af5f00255#ffffff0@1|1| |f+0#0000000&|i|r|s|t| |l|i|n|e| @45
+| +0#af5f00255&@3| +0#0000000&@1|o+0&#ffd7ff255|n|e| |b|e|l|o|w| |t|h|e| |t|e|x|t| |o|n|e| |b|e|l|o|w| |t|h|e| |t|e|x|t| |o|n|e| |b|e|l|o|w| |t|h|e| |t|e
+| +0#af5f00255#ffffff0@3| +0#0000000&@1|t+0&#ffd7ff255|w|o| |b|e|l|o|w| |t|h|e| |t|e|x|t| |t|w|o| |b|e|l|o|w| |t|h|e| |t|e|x|t| |t|w|o| |b|e|l|o|w| |t|h|e| |t|e
+| +0#af5f00255#ffffff0@1|2| |s+0#0000000&|e|c|o|n|d| >l|i|n|e| |s|e|c|o|n|d| |l|i|n|e| |s|e|c|o|n|d| |l|i|n|e| |s|e|c|o|n|d| |l|i|n|e| |s|e|c|o|n|d| |l
+| +0#af5f00255&@1|3| |t+0#0000000&|h|i|r|d| @50
+| +0#af5f00255&@1|4| |f+0#0000000&|o|u|r|t|h| @49
+|~+0#4040ff13&| @58
+| +0#0000000&@41|2|,|8| @10|A|l@1| 
index 5b0dce829cfe78599fa966d7a2b008643c12b828..624f23fbfbd3e3f31364241a57ca7ec71763922f 100644 (file)
@@ -3241,6 +3241,35 @@ func Test_text_after_nowrap()
   call StopVimInTerminal(buf)
 endfunc
 
+func Test_text_below_nowrap()
+  CheckRunVimInTerminal
+
+  let lines =<< trim END
+      vim9script
+      setline(1, ['first line', 'second line '->repeat(50), 'third', 'fourth'])
+      set nowrap number
+      prop_type_add('theprop', {highlight: 'DiffChange'})
+      prop_add(1, 0, {
+          type: 'theprop',
+          text: 'one below the text '->repeat(5),
+          text_align: 'below',
+          text_padding_left: 2,
+      })
+      prop_add(1, 0, {
+          type: 'theprop',
+          text: 'two below the text '->repeat(5),
+          text_align: 'below',
+          text_padding_left: 2,
+      })
+      normal 2Gw
+  END
+  call writefile(lines, 'XTextBelowNowrap', 'D')
+  let buf = RunVimInTerminal('-S XTextBelowNowrap', #{rows: 8, cols: 60})
+  call VerifyScreenDump(buf, 'Test_text_below_nowrap_1', {})
+
+  call StopVimInTerminal(buf)
+endfunc
+
 func Test_insert_text_change_arg()
   CheckRunVimInTerminal
 
index 2b57f7d1aa8bc41db2838f38983438ebe079c9e8..772267eff6331c92c51b64896ee957281a996c03 100644 (file)
@@ -699,6 +699,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    714,
 /**/
     713,
 /**/