feat(editor): handle new multibyte sequences in normal mode replacement

while the implementation is not tied to screen chars, it is a reasonable
expectation to support the same size. If nvim is able to display a
multibyte character, it will accept the same character as input,
including in normal mode commands like r{char}
This commit is contained in:
bfredl
2024-09-29 10:05:27 +02:00
parent 0da4d89558
commit 23290e7676
7 changed files with 73 additions and 40 deletions

View File

@@ -9,6 +9,7 @@ local feed = n.feed
local fn = n.fn
local command = n.command
local eq = t.eq
local api = n.api
describe('Normal mode', function()
before_each(clear)
@@ -41,4 +42,23 @@ describe('Normal mode', function()
attr_ids = {},
})
end)
it('replacing with ZWJ emoji sequences', function()
local screen = Screen.new(30, 8)
screen:attach()
api.nvim_buf_set_lines(0, 0, -1, true, { 'abcdefg' })
feed('05r🧑🌾') -- ZWJ
screen:expect([[
🧑‍🌾🧑‍🌾🧑‍🌾🧑‍🌾^🧑🌾fg |
{1:~ }|*6
|
]])
feed('2r🏳') -- ZWJ and variant selectors
screen:expect([[
🧑‍🌾🧑‍🌾🧑‍🌾🧑‍🌾🏳️‍⚧️^🏳g |
{1:~ }|*6
|
]])
end)
end)