From e3bfcf2fd4a4ebf00b104b082cfe83c8144a842d Mon Sep 17 00:00:00 2001 From: bfredl Date: Wed, 18 Dec 2024 14:49:38 +0100 Subject: feat(terminal): support grapheme clusters, including emoji --- test/functional/terminal/buffer_spec.lua | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'test/functional/terminal/buffer_spec.lua') diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua index e209ed9025..b6de687af9 100644 --- a/test/functional/terminal/buffer_spec.lua +++ b/test/functional/terminal/buffer_spec.lua @@ -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 = ('a̳'):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 }) -- cgit