feat(terminal): support grapheme clusters, including emoji

This commit is contained in:
bfredl
2024-12-18 14:49:38 +01:00
parent 9d9ee3476e
commit e3bfcf2fd4
11 changed files with 184 additions and 631 deletions

View File

@@ -400,15 +400,28 @@ describe(':terminal buffer', function()
assert_alive()
end)
it('truncates number of composing characters to 5', function()
it('truncates the size of grapheme clusters', function()
local chan = api.nvim_open_term(0, {})
local composing = (''):sub(2)
api.nvim_chan_send(chan, 'a' .. composing:rep(8))
api.nvim_chan_send(chan, 'a' .. composing:rep(20))
retry(nil, nil, function()
eq('a' .. composing:rep(5), api.nvim_get_current_line())
eq('a' .. composing:rep(14), api.nvim_get_current_line())
end)
end)
it('handles extended grapheme clusters', function()
local screen = Screen.new(50, 7)
feed 'i'
local chan = api.nvim_open_term(0, {})
api.nvim_chan_send(chan, '🏴‍☠️ yarrr')
screen:expect([[
🏴‍☠️ yarrr^ |
|*5
{5:-- TERMINAL --} |
]])
eq('🏴‍☠️ yarrr', api.nvim_get_current_line())
end)
it('handles split UTF-8 sequences #16245', function()
local screen = Screen.new(50, 7)
fn.jobstart({ testprg('shell-test'), 'UTF-8' }, { term = true })