[meld] Fix off-by-one highlighting in chunks containing CRLF linebreaks
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] Fix off-by-one highlighting in chunks containing CRLF linebreaks
- Date: Tue, 4 Jan 2011 20:11:51 +0000 (UTC)
commit 68f9c6691205299ac56427eea758bddee6c283f5
Author: Kai Willadsen <kai willadsen gmail com>
Date: Wed Jan 5 06:03:01 2011 +1000
Fix off-by-one highlighting in chunks containing CRLF linebreaks
After changing our line splitting code (in commit d6bb4e), linebreaks
were correctly removed from all lines. However, the existing inline
highlighting code relied on the fact that stray \r characters were
previously either left in the text, or removed from all internal
representations by Python's universal line handling.
As a result, in files with CRLF pairs, multi-line modified chunks would
have their inline change highlighting offset by a character, starting
from the second line of the chunk and increasing every line thereafter.
This change bypasses the problem by going back to the text buffer to
obtain the text for highlighting.
meld/filediff.py | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index 281c52e..175241e 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -1006,8 +1006,12 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
bufs[0].remove_tag(tags[0], starts[0], ends[0])
bufs[1].remove_tag(tags[1], starts[1], ends[1])
- text1 = "\n".join(alltexts[1][c[1]:c[2]])
- textn = "\n".join(alltexts[i * 2][c[3]:c[4]])
+ # We don't use self.buffer_texts here, as removing line
+ # breaks messes with inline highlighting in CRLF cases
+ text1 = bufs[0].get_text(starts[0], ends[0], False)
+ text1 = unicode(text1, 'utf8')
+ textn = bufs[1].get_text(starts[1], ends[1], False)
+ textn = unicode(textn, 'utf8')
# For very long sequences, bail rather than trying a very slow comparison
inline_limit = 8000 # arbitrary constant
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]