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:
Kovid Goyal 2018-06-15 08:08:21 +05:30
parent 5dfb8b1d80
commit 22cffef7c8
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -116,13 +116,9 @@ def collect_files(collection, left, right):
sanitize_pat = re.compile('[\x00-\x09\x0b-\x1f\x7f\x80-\x9f]') 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): def sanitize(text):
ntext = text.replace('\r\n', '\n') ntext = text.replace('\r\n', '\n')
return sanitize_pat.sub(sanitize_sub, ntext) return sanitize_pat.sub('', ntext)
@lru_cache(maxsize=1024) @lru_cache(maxsize=1024)