From 445e20d432bc6a036537816314007420c2498e19 Mon Sep 17 00:00:00 2001
From: Piotr Piastucki <leech miranda gmail com>
Date: Thu, 13 May 2010 09:10:27 +0200
Subject: [PATCH] Fix loading files with CRLF EOL
When CRLF appears exactly at the 4kb boundary a superfluous empty
line is inserted because CR and LF are inserted into the text buffer
separately. This patch changes the way files are loaded so that the whole
text is inserted into the buffer at once.
---
meld/filediff.py | 7 +------
1 files changed, 1 insertions(+), 6 deletions(-)
diff --git a/meld/filediff.py b/meld/filediff.py
index 246e054..0a432ef 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -702,7 +702,6 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
pane = i)
tasks.append(task)
except (IOError, LookupError), e:
- buf.delete(*buf.get_bounds())
add_dismissable_msg(i, gtk.STOCK_DIALOG_ERROR,
_("Could not read file"), str(e))
else:
@@ -713,7 +712,6 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
try:
nextbit = t.file.read(4096)
if nextbit.find("\x00") != -1:
- t.buf.delete(*t.buf.get_bounds())
add_dismissable_msg(t.pane, gtk.STOCK_DIALOG_ERROR,
_("Could not read file"),
_("%s appears to be a binary file.") % t.filename)
@@ -722,11 +720,9 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
t.codec.pop(0)
if len(t.codec):
t.file = codecs.open(t.filename, "rU", t.codec[0])
- t.buf.delete( t.buf.get_start_iter(), t.buf.get_end_iter() )
t.text = []
else:
print "codec error fallback", err
- t.buf.delete(*t.buf.get_bounds())
add_dismissable_msg(t.pane, gtk.STOCK_DIALOG_ERROR,
_("Could not read file"),
_("%s is not in encodings: %s") %
@@ -738,7 +734,6 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
tasks.remove(t)
else:
if len(nextbit):
- t.buf.insert( t.buf.get_end_iter(), nextbit )
t.text.append(nextbit)
else:
self.set_buffer_writable(t.buf, os.access(t.filename, os.W_OK))
@@ -747,9 +742,9 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
self.bufferdata[t.pane].newlines = t.file.newlines
tasks.remove(t)
if (self.prefs.supply_newline and t.text and not t.text[-1].endswith("\n")):
- t.buf.insert(t.buf.get_end_iter(), "\n")
t.text.append("\n")
panetext[t.pane] = "".join(t.text)
+ t.buf.insert( t.buf.get_end_iter(), panetext[t.pane] )
yield 1
def _diff_files(self, files, panetext):
--
1.7.0.4
Attachment:
msgdialog.c.tar.gz
Description: GNU Zip compressed data