From 22cffef7c8b7beae481a16a3b2458f651343b817 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 15 Jun 2018 08:08:21 +0530 Subject: [PATCH] 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 is in any case. --- kittens/diff/collect.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/kittens/diff/collect.py b/kittens/diff/collect.py index c468b53ec..0fc63d234 100644 --- a/kittens/diff/collect.py +++ b/kittens/diff/collect.py @@ -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)