mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-04 13:42:33 +02:00
diff kitten: Use a single-width replacement for control chars
Preserves text width better, and conveys the essential message, namely non-printable characters. Most people wont know what <hex code> is in any case.
This commit is contained in:
@@ -116,13 +116,9 @@ def collect_files(collection, left, right):
|
||||
sanitize_pat = re.compile('[\x00-\x09\x0b-\x1f\x7f\x80-\x9f]')
|
||||
|
||||
|
||||
def sanitize_sub(m):
|
||||
return '<{:x}>'.format(ord(m.group()[0]))
|
||||
|
||||
|
||||
def sanitize(text):
|
||||
ntext = text.replace('\r\n', '⏎\n')
|
||||
return sanitize_pat.sub(sanitize_sub, ntext)
|
||||
return sanitize_pat.sub('░', ntext)
|
||||
|
||||
|
||||
@lru_cache(maxsize=1024)
|
||||
|
||||
Reference in New Issue
Block a user