mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 03:48:18 +00:00
feat(mbyte): support extended grapheme clusters including more emoji
Use the grapheme break algorithm from utf8proc to support grapheme clusters from recent unicode versions. Handle variant selector VS16 turning some codepoints into double-width emoji. This means we need to use ptr2cells rather than char2cells when possible.
This commit is contained in:
@@ -1435,6 +1435,28 @@ describe('API', function()
|
||||
it('cannot handle NULs', function()
|
||||
eq(0, api.nvim_strwidth('\0abc'))
|
||||
end)
|
||||
|
||||
it('can handle emoji with variant selectors and ZWJ', function()
|
||||
local selector = '❤️'
|
||||
eq(2, fn.strchars(selector))
|
||||
eq(1, fn.strcharlen(selector))
|
||||
eq(2, api.nvim_strwidth(selector))
|
||||
|
||||
local no_selector = '❤'
|
||||
eq(1, fn.strchars(no_selector))
|
||||
eq(1, fn.strcharlen(no_selector))
|
||||
eq(1, api.nvim_strwidth(no_selector))
|
||||
|
||||
local selector_zwj_selector = '🏳️⚧️'
|
||||
eq(5, fn.strchars(selector_zwj_selector))
|
||||
eq(1, fn.strcharlen(selector_zwj_selector))
|
||||
eq(2, api.nvim_strwidth(selector_zwj_selector))
|
||||
|
||||
local emoji_zwj_emoji = '🧑🌾'
|
||||
eq(3, fn.strchars(emoji_zwj_emoji))
|
||||
eq(1, fn.strcharlen(emoji_zwj_emoji))
|
||||
eq(2, api.nvim_strwidth(emoji_zwj_emoji))
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('nvim_get_current_line, nvim_set_current_line', function()
|
||||
|
Reference in New Issue
Block a user