# HG changeset patch # User Thomas De Schampheleire # Date 2018-01-23 13:31:25 # Node ID f79c40759d6f6de3c7858b8871fcfb3c622fdb9d # Parent fcff67b0de83bae7cd09fc8a910b8f977984dd54 lib/diffs: mark trailing tabs similar to trailing spaces So far, spaces have not been marked up, but trailing spaces are followed by '' (newline symbol). Tabs have been marked up as '\t' (underlined with icon), but trailing tabs didn't get the same "trailing whitespace" markup as trailing spaces got. Fix this unfairness by handling trailing tabs explicitly as '\t' so they get both kinds of markup. diff --git a/kallithea/lib/diffs.py b/kallithea/lib/diffs.py --- a/kallithea/lib/diffs.py +++ b/kallithea/lib/diffs.py @@ -453,7 +453,7 @@ class DiffProcessor(object): return self.adds, self.removes -_escape_re = re.compile(r'(&)|(<)|(>)|(\t)|(\r)|(?<=.)( \n| $)') +_escape_re = re.compile(r'(&)|(<)|(>)|(\t)|(\r)|(?<=.)( \n| $)|(\t\n|\t$)') def _escaper(string): @@ -470,11 +470,13 @@ def _escaper(string): if groups[2]: return '>' if groups[3]: - return '\t' + return '\t' # Note: trailing tabs will get a longer match later if groups[4]: return '' if groups[5]: return ' ' + if groups[6]: + return '\t' assert False return _escape_re.sub(substitute, safe_str(string))