]> granicus.if.org Git - vim/commitdiff
patch 9.0.0158: with 'nowrap' "below" property not displayed correctly v9.0.0158
authorBram Moolenaar <Bram@vim.org>
Sat, 6 Aug 2022 21:03:20 +0000 (22:03 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 6 Aug 2022 21:03:20 +0000 (22:03 +0100)
Problem:    With 'nowrap' "below" property not displayed correctly.
Solution:   Adjust virtual text with 'nowrap', do not truncate.

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

index 26b52d3b1777f377595824702b6771e65bc46f73..fb662f71bdd5056aae807a32df9363fae1d1fc9c 100644 (file)
@@ -1642,9 +1642,15 @@ win_line(
                    --bcol;
 # endif
                // Add any text property that starts in this column.
+               // With 'nowrap' and not in the first screen line only "below"
+               // text prop can show.
                while (text_prop_next < text_prop_count
                           && (text_props[text_prop_next].tp_col == MAXCOL
-                             ? *ptr == NUL
+                             ? (*ptr == NUL
+                                 && (wp->w_p_wrap
+                                     || wlv.row == startrow
+                                     || (text_props[text_prop_next].tp_flags
+                                                      & TP_FLAG_ALIGN_BELOW)))
                              : bcol >= text_props[text_prop_next].tp_col - 1))
                {
                    if (bcol <= text_props[text_prop_next].tp_col - 1
@@ -1761,7 +1767,8 @@ win_line(
                                        vim_memset(l, ' ', added);
                                        vim_strncpy(l + added, wlv.p_extra,
                                                                       n_used);
-                                       if (n_used < wlv.n_extra)
+                                       if (n_used < wlv.n_extra
+                                                              && wp->w_p_wrap)
                                        {
                                            char_u *lp = l + added + n_used - 1;
 
@@ -1810,11 +1817,15 @@ 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)
+                          && ((*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))))
                    // 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;
            }
 #endif
@@ -3461,6 +3472,16 @@ win_line(
 #endif
                    ) || lcs_eol_one == -1)
                break;
+#ifdef FEAT_PROP_POPUP
+           if (!wp->w_p_wrap)
+           {
+               // do not output more of the line, only the "below" prop
+               ptr += STRLEN(ptr);
+# ifdef FEAT_LINEBREAK
+               dont_use_showbreak = TRUE;
+# endif
+           }
+#endif
 
            // When the window is too narrow draw all "@" lines.
            if (wlv.draw_state != WL_LINE
diff --git a/src/testdir/dumps/Test_prop_with_text_below_nowrap_1.dump b/src/testdir/dumps/Test_prop_with_text_below_nowrap_1.dump
new file mode 100644 (file)
index 0000000..e7f1837
--- /dev/null
@@ -0,0 +1,8 @@
+|o+0&#ffffff0|n|a|s|d|f| |a|s|d|f| |a|s|d|f| |s|d|f| |d|f| |a|s|d|f| |a|s|d|f| |e| |a|s|d|f| |a|s|d|f| |a|s|d|f| |a|s|d|f| |a|s|d| 
+|t+0#e000e06&|h|e| |q|u|i|c|k| |b|r|o|w|n| |f|o|x| |j|u|m|p|s| |o|v|e|r| |t|h|e| |l|a|z|y| |d|o|g| +0#0000000&@16
+|t|w>o| @56
+|~+0#4040ff13&| @58
+|~| @58
+|~| @58
+|~| @58
+|"+0#0000000&|f|o@1|b|a|r|"| |[|N|e|w|]| @27|2|,|3| @10|A|l@1| 
diff --git a/src/testdir/dumps/Test_prop_with_text_below_nowrap_2.dump b/src/testdir/dumps/Test_prop_with_text_below_nowrap_2.dump
new file mode 100644 (file)
index 0000000..0bcaf66
--- /dev/null
@@ -0,0 +1,8 @@
+| +0&#ffffff0|a|s|d|f| |a|s|d|f| |a|s|d|f| |a|s|d|f| |a|s|d| |f|a|s| |d>f|t+0#e000e06&|h|e| |q|u|i|c|k| |b|r|o|w|n| |f|o|x| |j|u|m|p|s| |o|v|e
+|t|h|e| |q|u|i|c|k| |b|r|o|w|n| |f|o|x| |j|u|m|p|s| |o|v|e|r| |t|h|e| |l|a|z|y| |d|o|g| +0#0000000&@16
+@60
+|~+0#4040ff13&| @58
+|~| @58
+|~| @58
+|~| @58
+|"+0#0000000&|f|o@1|b|a|r|"| |[|N|e|w|]| @27|1|,|6@1| @9|A|l@1| 
index 484cb3cea43e7b68e7ca0002fa85123dda7ad4d7..8f3a304509961d6297c0d4f1e3e19d1947b51b5b 100644 (file)
@@ -2482,6 +2482,39 @@ func Test_props_with_text_after_nowrap()
   call delete('XscriptPropsAfterNowrap')
 endfunc
 
+func Test_props_with_text_below_nowrap()
+  CheckRunVimInTerminal
+
+  let lines =<< trim END
+      vim9script
+      edit foobar
+      set nowrap
+      set showbreak=+++\ 
+      setline(1, ['onasdf asdf asdf sdf df asdf asdf e asdf asdf asdf asdf asd fas df', 'two'])
+      prop_type_add('test', {highlight: 'Special'})
+      prop_add(1, 0, {
+          type: 'test',
+          text: 'the quick brown fox jumps over the lazy dog',
+          text_align: 'after'
+      })
+      prop_add(1, 0, {
+          type: 'test',
+          text: 'the quick brown fox jumps over the lazy dog',
+          text_align: 'below'
+      })
+      normal G$
+  END
+  call writefile(lines, 'XscriptPropsBelowNowrap')
+  let buf = RunVimInTerminal('-S XscriptPropsBelowNowrap', #{rows: 8, cols: 60})
+  call VerifyScreenDump(buf, 'Test_prop_with_text_below_nowrap_1', {})
+
+  call term_sendkeys(buf, "gg$")
+  call VerifyScreenDump(buf, 'Test_prop_with_text_below_nowrap_2', {})
+
+  call StopVimInTerminal(buf)
+  call delete('XscriptPropsBelowNowrap')
+endfunc
+
 func Test_props_with_text_after_split_join()
   CheckRunVimInTerminal
 
index 667b6071bd9dedf18450949992dd58746e6c1d58..0a39e5d9d73fc7b0dea36af46b3a64fc8bf0e7b4 100644 (file)
@@ -735,6 +735,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    158,
 /**/
     157,
 /**/