aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorIbby <33922797+SleepySwords@users.noreply.github.com>2023-03-19 20:31:52 +1100
committerbfredl <bjorn.linse@gmail.com>2023-05-22 13:49:42 +0200
commit0c7fa3bdcc3761cc851ea0ac37bf692b990044cc (patch)
tree8876f39c6edd4c72bfa369abcc53f8b0279df3da /test
parent389f5ca39d278173dc0446dc339f7ac1ff573329 (diff)
downloadrneovim-0c7fa3bdcc3761cc851ea0ac37bf692b990044cc.tar.gz
rneovim-0c7fa3bdcc3761cc851ea0ac37bf692b990044cc.tar.bz2
rneovim-0c7fa3bdcc3761cc851ea0ac37bf692b990044cc.zip
fix(ui): fix multi-byte characters highlight in virtual text
This also fixes insert cursor position around virtual text vim-patch:9.0.0132: multi-byte characters in virtual text not handled correctly Problem: Multi-byte characters in virtual text not handled correctly. Solution: Count screen cells instead of bytes. https://github.com/vim/vim/commit/09ff4b54fb86a64390ba9c609853c6410ea6197c
Diffstat (limited to 'test')
-rw-r--r--test/functional/ui/decorations_spec.lua84
1 files changed, 77 insertions, 7 deletions
diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua
index 94267e35c4..6e4b19c856 100644
--- a/test/functional/ui/decorations_spec.lua
+++ b/test/functional/ui/decorations_spec.lua
@@ -1254,7 +1254,7 @@ end]]
{ virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' })
feed '^'
feed '4l'
- screen:expect { grid = [[
+ screen:expect { grid = [[
1234{28: virtual text virtual text }^5678 |
{1:~ }|
{1:~ }|
@@ -1274,12 +1274,12 @@ end]]
end)
it('adjusts cursor location correctly when inserting around inline virtual text', function()
- insert('12345678')
- feed '$'
- meths.buf_set_extmark(0, ns, 0, 4,
+ insert('12345678')
+ feed '$'
+ meths.buf_set_extmark(0, ns, 0, 4,
{ virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' })
- screen:expect { grid = [[
+ screen:expect { grid = [[
1234{28: virtual text }567^8 |
{1:~ }|
{1:~ }|
@@ -1295,8 +1295,78 @@ end]]
{1:~ }|
{1:~ }|
|
- ]]
- }
+ ]]}
+ end)
+
+ it('has correct highlighting with multi-byte characters in inline virtual text', function()
+ insert('12345678')
+ meths.buf_set_extmark(0, ns, 0, 4,
+ { virt_text = { { 'múlti-byté chñröcters 修补', 'Special' } }, virt_text_pos = 'inline' })
+
+ screen:expect { grid = [[
+ 1234{28:múlti-byté chñröcters 修补}567^8 |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ |
+ ]]}
+ end)
+
+ it('has correct cursor position when inserting around virtual text', function()
+ insert('12345678')
+ meths.buf_set_extmark(0, ns, 0, 4,
+ { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' })
+ feed '^'
+ feed '3l'
+ feed 'a'
+ screen:expect { grid = [[
+ 1234{28:^virtual text}5678 |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {24:-- INSERT --} |
+ ]]}
+ feed '<ESC>'
+ feed '^'
+ feed '4l'
+ feed 'i'
+ screen:expect { grid = [[
+ 1234{28:^virtual text}5678 |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {24:-- INSERT --} |
+ ]]}
end)
end)