diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-07-07 07:21:12 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-07 07:21:12 +0800 |
commit | 36941942d60915d9f78defd6aaf713a27952e16a (patch) | |
tree | cb3c9ab9d44b4822e8b9328009243e9f3e2c4237 | |
parent | 06c4edf46bf65ec6b540de355cf1a691533f1df9 (diff) | |
download | rneovim-36941942d60915d9f78defd6aaf713a27952e16a.tar.gz rneovim-36941942d60915d9f78defd6aaf713a27952e16a.tar.bz2 rneovim-36941942d60915d9f78defd6aaf713a27952e16a.zip |
fix(drawline): inline virt_text hl_mode inside syntax/extmark hl (#24273)
-rw-r--r-- | src/nvim/drawline.c | 18 | ||||
-rw-r--r-- | test/functional/ui/decorations_spec.lua | 43 |
2 files changed, 55 insertions, 6 deletions
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index 029a89f109..9bfe2da214 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -1114,10 +1114,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl bool area_highlighting = false; // Visual or incsearch highlighting in this line int vi_attr = 0; // attributes for Visual and incsearch highlighting int area_attr = 0; // attributes desired by highlighting - int saved_area_attr = 0; // idem for area_attr int search_attr = 0; // attributes desired by 'hlsearch' - int saved_search_attr = 0; // search_attr to be used when n_extra - // goes to zero int vcol_save_attr = 0; // saved attr for 'cursorcolumn' int decor_attr = 0; // attributes desired by syntax and extmarks bool has_syntax = false; // this buffer has syntax highl. @@ -1150,8 +1147,13 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl int prev_c1 = 0; // first composing char for prev_c bool search_attr_from_match = false; // if search_attr is from :match - bool saved_search_attr_from_match = false; // if search_attr is from :match bool has_decor = false; // this buffer has decoration + + int saved_search_attr = 0; // search_attr to be used when n_extra goes to zero + int saved_area_attr = 0; // idem for area_attr + int saved_decor_attr = 0; // idem for decor_attr + bool saved_search_attr_from_match = false; + int win_col_offset = 0; // offset for window columns char buf_fold[FOLD_TEXT_LEN]; // Hold value returned by get_foldtext @@ -1836,11 +1838,12 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl // TODO(bfredl): this is ugly as fuck. look if we can do this some other way. saved_search_attr = search_attr; saved_area_attr = area_attr; + saved_decor_attr = decor_attr; saved_search_attr_from_match = search_attr_from_match; - search_attr_from_match = false; search_attr = 0; area_attr = 0; - extmark_attr = 0; + decor_attr = 0; + search_attr_from_match = false; n_skip = 0; } } @@ -2014,6 +2017,9 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl if (area_attr == 0 && *ptr != NUL) { area_attr = saved_area_attr; } + if (decor_attr == 0) { + decor_attr = saved_decor_attr; + } if (wlv.extra_for_extmark) { // wlv.extra_attr should be used at this position but not diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 8070ac550d..0c4df563cc 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -2107,6 +2107,49 @@ bbbbbbb]]) ]]} end) + it('inside highlight range of another extmark', function() + insert('foo foo foo foo\nfoo foo foo foo') + meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + meths.buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + meths.buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'DDD', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) + meths.buf_set_extmark(0, ns, 0, 4, { end_col = 11, hl_group = 'Search' }) + meths.buf_set_extmark(0, ns, 1, 4, { end_col = 11, hl_group = 'Search' }) + screen:expect{grid=[[ + foo {12:foo }{10:AAA}{19:BBB}{12:foo} foo | + foo {12:foo }{19:CCC}{10:DDD}{12:foo} fo^o | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) + + it('inside highlight range of syntax', function() + insert('foo foo foo foo\nfoo foo foo foo') + meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + meths.buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + meths.buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'DDD', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) + command([[syntax match Search 'foo \zsfoo foo\ze foo']]) + screen:expect{grid=[[ + foo {12:foo }{10:AAA}{19:BBB}{12:foo} foo | + foo {12:foo }{19:CCC}{10:DDD}{12:foo} fo^o | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) + it('cursor position is correct when inserting around a virtual text with right gravity set to false', function() insert('foo foo foo foo') meths.buf_set_extmark(0, ns, 0, 8, |