# HG changeset patch # User Mads Kiilerich # Date 2014-12-15 13:47:36 # Node ID 960248c6e021a0883d31787c26b6ec122767ab83 # Parent ed4a3c0fe61a9bea4b07a152f7a7faa62876d2e9 diff: preserve leading space on empty lines - don't match in re if we don't plan to replace Fix invisible bug from 7c094db329b3, exposed by future exact parsing of diffs. diff --git a/kallithea/lib/diffs.py b/kallithea/lib/diffs.py --- a/kallithea/lib/diffs.py +++ b/kallithea/lib/diffs.py @@ -194,7 +194,7 @@ class DiffProcessor(object): #used for inline highlighter word split _token_re = re.compile(r'()(>|<|&|\t| |\W+?)') - _escape_re = re.compile(r'(&)|(<)|(>)|(\t)|( \n| $)') + _escape_re = re.compile(r'(&)|(<)|(>)|(\t)|(?<=.)( \n| $)') def __init__(self, diff, vcs='hg', format='gitdiff', diff_limit=None): @@ -261,8 +261,9 @@ class DiffProcessor(object): return '>' if groups[3]: return '\t' - if groups[4] and m.start(): # skip 1st column with +/- + if groups[4]: return ' ' + assert False return self._escape_re.sub(substitute, safe_unicode(string))