Add tests for strip_csi with multibyte

This commit is contained in:
Kovid Goyal 2024-11-24 09:28:21 +05:30
parent ebb733bad0
commit 0eaf44d33d
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 3 additions and 2 deletions

View file

@ -87,7 +87,7 @@ strip_csi_(const char *title, char *buf, size_t bufsz) {
} break;
case IN_CSI: {
if (!(('0' <= ch && ch <= '9') || ch == ';' || ch == ':')) {
if (ch >= ' ' && ch != DEL) *(dest++) = ch;
if (ch > DEL) *(dest++) = ch; // UTF-8 multibyte
state = NORMAL;
}
} break;

View file

@ -560,9 +560,10 @@ class TestDataTypes(BaseTest):
def q(x, y=''):
self.ae(y or x, strip_csi(x))
q('test')
q('a\x1bbc', 'ac')
q('a\x1bbc', 'abc')
q('a\x1b[bc', 'ac')
q('a\x1b[12;34:43mbc', 'abc')
q('a\x1b[12;34:43\U0001f638', 'a\U0001f638')
def test_single_key(self):
from kitty.fast_data_types import GLFW_MOD_KITTY, GLFW_MOD_SHIFT, SingleKey