mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-12 19:49:32 +02:00
Unicode input: When searching by name search for prefix matches as well as whole word matches
So now hori matches both "hori" and "horizontal". Switched to a prefix-trie internally.
This commit is contained in:
22
kitty_tests/unicode_input.py
Normal file
22
kitty_tests/unicode_input.py
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
|
||||
from . import BaseTest
|
||||
|
||||
|
||||
class TestUnicodeInput(BaseTest):
|
||||
|
||||
def test_word_trie(self):
|
||||
from kittens.unicode_input.unicode_names import codepoints_for_word
|
||||
|
||||
def matches(a, *words):
|
||||
ans = codepoints_for_word(a)
|
||||
for w in words:
|
||||
ans &= codepoints_for_word(w)
|
||||
return set(ans)
|
||||
|
||||
self.ae(matches('horiz', 'ell'), {0x2026, 0x22ef, 0x2b2c, 0x2b2d, 0xfe19})
|
||||
self.ae(matches('horizontal', 'ell'), {0x2026, 0x22ef, 0x2b2c, 0x2b2d, 0xfe19})
|
||||
self.assertFalse(matches('sfgsfgsfgfgsdg'))
|
||||
Reference in New Issue
Block a user