changeset 8560:f79c40759d6f

lib/diffs: mark trailing tabs similar to trailing spaces So far, spaces have not been marked up, but trailing spaces are followed by '<i></i>' (newline symbol). Tabs have been marked up as '<u>\t</u>' (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 '<u>\t</u><i></i>' so they get both kinds of markup.
author Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
date Tue, 23 Jan 2018 13:31:25 +0100
parents fcff67b0de83
children 5fe492c6d7d7
files kallithea/lib/diffs.py
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/diffs.py	Sun Mar 22 00:14:06 2020 +0100
+++ b/kallithea/lib/diffs.py	Tue Jan 23 13:31:25 2018 +0100
@@ -453,7 +453,7 @@
         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 @@
         if groups[2]:
             return '&gt;'
         if groups[3]:
-            return '<u>\t</u>'
+            return '<u>\t</u>'  # Note: trailing tabs will get a longer match later
         if groups[4]:
             return '<u class="cr"></u>'
         if groups[5]:
             return ' <i></i>'
+        if groups[6]:
+            return '<u>\t</u><i></i>'
         assert False
 
     return _escape_re.sub(substitute, safe_str(string))