summaryrefslogtreecommitdiffstats
path: root/src/drawline.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-10-10 19:50:42 +0100
committerBram Moolenaar <Bram@vim.org>2022-10-10 19:50:42 +0100
commitcd105417a53fcf97c0935f3468201ef11516c9f1 (patch)
treeb1682f82a1ea256a9968579c1c1d6c4bd4c96c42 /src/drawline.c
parent801cd35e7e3b21e519e12a1610ee1d721e40893e (diff)
patch 9.0.0716: with 'nowrap' virtual text "after" does not scroll leftv9.0.0716
Problem: With 'nowrap' virtual text "after" does not scroll left. Solution: Skip part of the virtual text that is left of the window. (closes #11320) Fix going beyond the last column of the window.
Diffstat (limited to 'src/drawline.c')
-rw-r--r--src/drawline.c53
1 files changed, 48 insertions, 5 deletions
diff --git a/src/drawline.c b/src/drawline.c
index 9aad81b9cc..f02e4f3a2f 100644
--- a/src/drawline.c
+++ b/src/drawline.c
@@ -975,7 +975,11 @@ win_line(
int n_attr3 = 0; // chars with overruling special attr
int saved_attr3 = 0; // char_attr saved for n_attr3
- int n_skip = 0; // nr of chars to skip for 'nowrap'
+ int n_skip = 0; // nr of cells to skip for 'nowrap' or
+ // concealing
+ int skip_cells = 0; // nr of cells to skip for virtual text
+ // after the line, when w_skipcol is
+ // larger than the text length
int fromcol_prev = -2; // start of inverting after cursor
int noinvcur = FALSE; // don't invert the cursor
@@ -1504,6 +1508,11 @@ win_line(
n_skip = v - wlv.vcol;
}
+ // If there the text doesn't reach to the desired column, need to skip
+ // "skip_cells" cells when virtual text follows.
+ if (!wp->w_p_wrap && v > wlv.vcol)
+ skip_cells = v - wlv.vcol;
+
// Adjust for when the inverted text is before the screen,
// and when the start of the inverted text is before the screen.
if (wlv.tocol <= wlv.vcol)
@@ -1897,10 +1906,20 @@ win_line(
int tpi = text_prop_idxs[pi];
textprop_T *tp = &text_props[tpi];
proptype_T *pt = text_prop_type_by_id(
- wp->w_buffer, tp->tp_type);
-
- if (pt != NULL && (pt->pt_hl_id > 0
- || tp->tp_id < 0) && tp->tp_id != -MAXCOL)
+ wp->w_buffer, tp->tp_type);
+
+ // Only use a text property that can be displayed.
+ // Skip "after" properties when wrap is off and at the
+ // end of the window.
+ if (pt != NULL
+ && (pt->pt_hl_id > 0 || tp->tp_id < 0)
+ && tp->tp_id != -MAXCOL
+ && !(tp->tp_id < 0
+ && !wp->w_p_wrap
+ && (tp->tp_flags & (TP_FLAG_ALIGN_RIGHT
+ | TP_FLAG_ALIGN_ABOVE
+ | TP_FLAG_ALIGN_BELOW)) == 0
+ && wlv.col >= wp->w_width))
{
if (pt->pt_hl_id > 0)
used_attr = syn_id2attr(pt->pt_hl_id);
@@ -2015,6 +2034,30 @@ win_line(
}
}
+ // If the text didn't reach until the first window
+ // column we need to skip cells.
+ if (skip_cells > 0)
+ {
+ if (wlv.n_extra > skip_cells)
+ {
+ wlv.n_extra -= skip_cells;
+ wlv.p_extra += skip_cells;
+ n_attr_skip -= skip_cells;
+ if (n_attr_skip < 0)
+ n_attr_skip = 0;
+ skip_cells = 0;
+ }
+ else
+ {
+ // the whole text is left of the window, drop
+ // it and advance to the next one
+ skip_cells -= wlv.n_extra;
+ wlv.n_extra = 0;
+ n_attr_skip = 0;
+ bail_out = TRUE;
+ }
+ }
+
// If another text prop follows the condition below at
// the last window column must know.
// If this is an "above" text prop and 'nowrap' the we