Re: [PATCH] Fix CRLF handling
- From: Piotr Piastucki <leech miranda gmail com>
- To: Kai Willadsen <kai willadsen gmail com>
- Cc: meld-list <meld-list gnome org>
- Subject: Re: [PATCH] Fix CRLF handling
- Date: Tue, 1 Jun 2010 08:41:43 +0200
Hi,
Here is another version of the fix.
Unfortunately, set_text() approach results in scrollbar flickering and
it is much slower.
Thanks,
Piotr
From 8f647875adc094165b20af5cf709df77c413d3fd Mon Sep 17 00:00:00 2001
From: Piotr Piastucki <leech miranda gmail com>
Date: Mon, 31 May 2010 08:42:00 +0200
Subject: [PATCH] Fix CRLF files loading
When CRLF appears exactly at the 4kb boundary a superfluous
empty line is inserted because CR and LF are separately inserted
into text buffer. This patch fixes the issue by adding a simple
check for CR occurence at the end of string being inserted.
---
meld/filediff.py | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/meld/filediff.py b/meld/filediff.py
index c5415a6..64fb350 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -699,7 +699,8 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
buf = buf,
codec = try_codecs[:],
text = [],
- pane = i)
+ pane = i,
+ was_cr = False)
tasks.append(task)
except (IOError, LookupError), e:
buf.delete(*buf.get_bounds())
@@ -737,7 +738,13 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
_("Could not read file"), str(ioerr))
tasks.remove(t)
else:
+ if t.was_cr:
+ nextbit = "\r" + nextbit
+ t.was_cr = False
if len(nextbit):
+ if (nextbit[-1] == "\r"):
+ t.was_cr = True
+ nextbit = nextbit[0:-1]
t.buf.insert( t.buf.get_end_iter(), nextbit )
t.text.append(nextbit)
else:
--
1.7.0.4
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]