aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIbby <33922797+SleepySwords@users.noreply.github.com>2023-04-03 20:46:50 +1000
committerbfredl <bjorn.linse@gmail.com>2023-05-22 13:49:42 +0200
commitecf225df574a48a4bbddf4978972b2b97184e92c (patch)
treea2bfd20eff65aae8603a3d3d1ac10d74e9e9b4ce
parent5d7afb2e9f222c32dd18c9c2bca49cab8bf751bc (diff)
downloadrneovim-ecf225df574a48a4bbddf4978972b2b97184e92c.tar.gz
rneovim-ecf225df574a48a4bbddf4978972b2b97184e92c.tar.bz2
rneovim-ecf225df574a48a4bbddf4978972b2b97184e92c.zip
vim-patch:9.0.0944: 'cursorline' causes virtual text highlight to continue
Problem: 'cursorline' causes virtual text highlight to continue. Solution: Save and restore line_attr. (closes vim/vim#11588) https://github.com/vim/vim/commit/6ac16f0c0fe923098b9df5ac430f1923045f16ea Co-authored-by: Bram Moolenaar <Bram@vim.org>
-rw-r--r--src/nvim/drawline.c18
-rw-r--r--test/functional/ui/decorations_spec.lua25
2 files changed, 43 insertions, 0 deletions
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c
index fddf1362a3..c063425f68 100644
--- a/src/nvim/drawline.c
+++ b/src/nvim/drawline.c
@@ -102,6 +102,7 @@ typedef struct {
///< when c_extra and c_final are NUL
char *p_extra_free; ///< p_extra buffer that needs to be freed
int extra_attr; ///< attributes for p_extra
+ ///< with win_attr if needed
int c_extra; ///< extra chars, all the same
int c_final; ///< final char, mandatory if set
@@ -923,6 +924,7 @@ static void win_line_continue(winlinevars_T *wlv)
if (wlv->saved_n_extra > 0) {
// Continue item from end of wrapped line.
wlv->n_extra = wlv->saved_n_extra;
+ wlv->saved_n_extra = 0;
wlv->c_extra = wlv->saved_c_extra;
wlv->c_final = wlv->saved_c_final;
wlv->p_extra = wlv->saved_p_extra;
@@ -985,6 +987,8 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
int search_attr = 0; // attributes desired by 'hlsearch'
int saved_search_attr = 0; // search_attr to be used when n_extra
// goes to zero
+ bool reset_extra_attr = false;
+
int vcol_save_attr = 0; // saved attr for 'cursorcolumn'
int syntax_attr = 0; // attributes desired by syntax
bool has_syntax = false; // this buffer has syntax highl.
@@ -1766,6 +1770,10 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
}
}
+ if (wlv.n_extra == 0) {
+ reset_extra_attr = false;
+ }
+
if (wlv.n_extra <= 0 && virt_inline_i < kv_size(virt_inline)) {
VirtTextChunk vtc = kv_A(virt_inline, virt_inline_i);
wlv.p_extra = vtc.text;
@@ -1931,6 +1939,9 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
wlv.p_extra++;
}
wlv.n_extra--;
+
+ // Only restore search_attr and area_attr after "n_extra" in
+ // the next screen line is also done.
if (wlv.n_extra <= 0) {
if (search_attr == 0) {
search_attr = saved_search_attr;
@@ -1938,6 +1949,9 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
if (area_attr == 0 && *ptr != NUL) {
area_attr = saved_area_attr;
}
+ // wlv.extra_attr should be used at this position but not
+ // any further.
+ reset_extra_attr = true;
}
} else if (foldinfo.fi_lines > 0) {
// skip writing the buffer line itself
@@ -2589,6 +2603,10 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
// Don't override visual selection highlighting.
if (n_attr > 0 && wlv.draw_state == WL_LINE && !search_attr_from_match) {
wlv.char_attr = hl_combine_attr(wlv.char_attr, wlv.extra_attr);
+ if (reset_extra_attr) {
+ reset_extra_attr = false;
+ wlv.extra_attr = 0;
+ }
}
// Handle the case where we are in column 0 but not on the first
diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua
index 9be8c23ba4..77748eecb3 100644
--- a/test/functional/ui/decorations_spec.lua
+++ b/test/functional/ui/decorations_spec.lua
@@ -1818,6 +1818,31 @@ bbbbbbb]])
|
]]}
end)
+
+ it('highlighting does not extend when no wrap is enabled with a long virtual text', function()
+ insert('abcdef')
+ command("set nowrap")
+ meths.buf_set_extmark(0, ns, 0, 3,
+ { virt_text = { { string.rep('X', 50), 'Special' } }, virt_text_pos = 'inline', right_gravity = false })
+ feed('$')
+ screen:expect { grid = [[
+ {28:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}de^f|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ |
+ ]]}
+ end)
end)
describe('decorations: virtual lines', function()