diff options
-rw-r--r-- | src/nvim/drawline.c | 2 | ||||
-rw-r--r-- | test/functional/ui/decorations_spec.lua | 37 |
2 files changed, 38 insertions, 1 deletions
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index 6480c10c6b..a4d98f09f4 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -337,7 +337,7 @@ static int draw_virt_text_item(buf_T *buf, int col, VirtText vt, HlMode hl_mode, schar_T dummy[2] = { schar_from_ascii(' '), schar_from_ascii(' ') }; int maxcells = max_col - col; // When overwriting the right half of a double-width char, clear the left half. - if (linebuf_char[col] == 0) { + if (!through && linebuf_char[col] == 0) { assert(col > 0); linebuf_char[col - 1] = schar_from_ascii(' '); // Clear the right half as well for the assertion in line_putchar(). diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 4860009e38..d6a0205b7e 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -2112,6 +2112,43 @@ describe('extmark decorations', function() ]]} end) + it('virtual text blending space does not overwrite double-width char', function() + screen:try_resize(50, 3) + insert('abcdefghij口klmnopqrstu口vwx口yz') + feed('0') + command('hi Blendy guibg=Red blend=30') + meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{' ! ! ', 'Blendy'}}, virt_text_win_col = 8, hl_mode = 'blend' }) + screen:expect{grid=[[ + ^abcdefgh{10:i}{7:!}{10:口}{7:!}{10:l}mnopqrstu口vwx口yz | + {1:~ }| + | + ]]} + feed('x') + screen:expect{grid=[[ + ^bcdefghi{10:j}{7:!}{10: k}{7:!}{10:m}nopqrstu口vwx口yz | + {1:~ }| + | + ]]} + feed('x') + screen:expect{grid=[[ + ^cdefghij{10: }{7:!}{10:kl}{7:!}{10:n}opqrstu口vwx口yz | + {1:~ }| + | + ]]} + feed('x') + screen:expect{grid=[[ + ^defghij口{7:!}{10:lm}{7:!}{10:o}pqrstu口vwx口yz | + {1:~ }| + | + ]]} + feed('7x') + screen:expect{grid=[[ + ^口klmnop{10:q}{7:!}{10:st}{7:!}{10:口}vwx口yz | + {1:~ }| + | + ]]} + end) + it('virtual text works with double-width char and rightleft', function() screen:try_resize(50, 3) insert('abcdefghij口klmnopqrstu口vwx口yz') |