Port code to truncate strings to visual width to Go

This commit is contained in:
Kovid Goyal
2022-09-18 13:17:39 +05:30
parent d16ad40bbf
commit 8796168469
3 changed files with 116 additions and 1 deletions

View File

@@ -398,9 +398,10 @@ class TestDataTypes(BaseTest):
self.ae(tpl('a\U0001f337', 2), 1)
self.ae(tpl('a\U0001f337', 3), 2)
self.ae(tpl('a\U0001f337b', 4), 3)
self.ae(sanitize_title('a\0\01 \t\n\f\rb'), 'a b')
self.ae(tpl('a\x1b[31mbc', 2), 7)
self.ae(sanitize_title('a\0\01 \t\n\f\rb'), 'a b')
def tp(*data, leftover='', text='', csi='', apc='', ibp=False):
text_r, csi_r, apc_r, rest = [], [], [], []
left = ''