Mercurial > vim
comparison src/drawline.c @ 30763:8ea77a6ceff0 v9.0.0716
patch 9.0.0716: with 'nowrap' virtual text "after" does not scroll left
Commit: https://github.com/vim/vim/commit/cd105417a53fcf97c0935f3468201ef11516c9f1
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Oct 10 19:50:42 2022 +0100
patch 9.0.0716: with 'nowrap' virtual text "after" does not scroll left
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 10 Oct 2022 21:00:05 +0200 |
parents | b41ccaa6fd84 |
children | 3002177fa0b1 |
comparison
equal
deleted
inserted
replaced
30762:df5ddde37685 | 30763:8ea77a6ceff0 |
---|---|
973 int n_attr_skip = 0; // chars to skip before using extra_attr | 973 int n_attr_skip = 0; // chars to skip before using extra_attr |
974 int saved_attr2 = 0; // char_attr saved for n_attr | 974 int saved_attr2 = 0; // char_attr saved for n_attr |
975 int n_attr3 = 0; // chars with overruling special attr | 975 int n_attr3 = 0; // chars with overruling special attr |
976 int saved_attr3 = 0; // char_attr saved for n_attr3 | 976 int saved_attr3 = 0; // char_attr saved for n_attr3 |
977 | 977 |
978 int n_skip = 0; // nr of chars to skip for 'nowrap' | 978 int n_skip = 0; // nr of cells to skip for 'nowrap' or |
979 // concealing | |
980 int skip_cells = 0; // nr of cells to skip for virtual text | |
981 // after the line, when w_skipcol is | |
982 // larger than the text length | |
979 | 983 |
980 int fromcol_prev = -2; // start of inverting after cursor | 984 int fromcol_prev = -2; // start of inverting after cursor |
981 int noinvcur = FALSE; // don't invert the cursor | 985 int noinvcur = FALSE; // don't invert the cursor |
982 int lnum_in_visual_area = FALSE; | 986 int lnum_in_visual_area = FALSE; |
983 pos_T pos; | 987 pos_T pos; |
1502 if (((*mb_ptr2cells)(ptr) >= charsize || *ptr == TAB) | 1506 if (((*mb_ptr2cells)(ptr) >= charsize || *ptr == TAB) |
1503 && wlv.col == 0) | 1507 && wlv.col == 0) |
1504 n_skip = v - wlv.vcol; | 1508 n_skip = v - wlv.vcol; |
1505 } | 1509 } |
1506 | 1510 |
1511 // If there the text doesn't reach to the desired column, need to skip | |
1512 // "skip_cells" cells when virtual text follows. | |
1513 if (!wp->w_p_wrap && v > wlv.vcol) | |
1514 skip_cells = v - wlv.vcol; | |
1515 | |
1507 // Adjust for when the inverted text is before the screen, | 1516 // Adjust for when the inverted text is before the screen, |
1508 // and when the start of the inverted text is before the screen. | 1517 // and when the start of the inverted text is before the screen. |
1509 if (wlv.tocol <= wlv.vcol) | 1518 if (wlv.tocol <= wlv.vcol) |
1510 wlv.fromcol = 0; | 1519 wlv.fromcol = 0; |
1511 else if (wlv.fromcol >= 0 && wlv.fromcol < wlv.vcol) | 1520 else if (wlv.fromcol >= 0 && wlv.fromcol < wlv.vcol) |
1895 for (pi = 0; pi < text_props_active; ++pi) | 1904 for (pi = 0; pi < text_props_active; ++pi) |
1896 { | 1905 { |
1897 int tpi = text_prop_idxs[pi]; | 1906 int tpi = text_prop_idxs[pi]; |
1898 textprop_T *tp = &text_props[tpi]; | 1907 textprop_T *tp = &text_props[tpi]; |
1899 proptype_T *pt = text_prop_type_by_id( | 1908 proptype_T *pt = text_prop_type_by_id( |
1900 wp->w_buffer, tp->tp_type); | 1909 wp->w_buffer, tp->tp_type); |
1901 | 1910 |
1902 if (pt != NULL && (pt->pt_hl_id > 0 | 1911 // Only use a text property that can be displayed. |
1903 || tp->tp_id < 0) && tp->tp_id != -MAXCOL) | 1912 // Skip "after" properties when wrap is off and at the |
1913 // end of the window. | |
1914 if (pt != NULL | |
1915 && (pt->pt_hl_id > 0 || tp->tp_id < 0) | |
1916 && tp->tp_id != -MAXCOL | |
1917 && !(tp->tp_id < 0 | |
1918 && !wp->w_p_wrap | |
1919 && (tp->tp_flags & (TP_FLAG_ALIGN_RIGHT | |
1920 | TP_FLAG_ALIGN_ABOVE | |
1921 | TP_FLAG_ALIGN_BELOW)) == 0 | |
1922 && wlv.col >= wp->w_width)) | |
1904 { | 1923 { |
1905 if (pt->pt_hl_id > 0) | 1924 if (pt->pt_hl_id > 0) |
1906 used_attr = syn_id2attr(pt->pt_hl_id); | 1925 used_attr = syn_id2attr(pt->pt_hl_id); |
1907 text_prop_type = pt; | 1926 text_prop_type = pt; |
1908 text_prop_attr = | 1927 text_prop_attr = |
2010 break; | 2029 break; |
2011 } | 2030 } |
2012 win_line_start(wp, &wlv, TRUE); | 2031 win_line_start(wp, &wlv, TRUE); |
2013 bail_out = TRUE; | 2032 bail_out = TRUE; |
2014 } | 2033 } |
2034 } | |
2035 } | |
2036 | |
2037 // If the text didn't reach until the first window | |
2038 // column we need to skip cells. | |
2039 if (skip_cells > 0) | |
2040 { | |
2041 if (wlv.n_extra > skip_cells) | |
2042 { | |
2043 wlv.n_extra -= skip_cells; | |
2044 wlv.p_extra += skip_cells; | |
2045 n_attr_skip -= skip_cells; | |
2046 if (n_attr_skip < 0) | |
2047 n_attr_skip = 0; | |
2048 skip_cells = 0; | |
2049 } | |
2050 else | |
2051 { | |
2052 // the whole text is left of the window, drop | |
2053 // it and advance to the next one | |
2054 skip_cells -= wlv.n_extra; | |
2055 wlv.n_extra = 0; | |
2056 n_attr_skip = 0; | |
2057 bail_out = TRUE; | |
2015 } | 2058 } |
2016 } | 2059 } |
2017 | 2060 |
2018 // If another text prop follows the condition below at | 2061 // If another text prop follows the condition below at |
2019 // the last window column must know. | 2062 // the last window column must know. |