Hi, I have noticed an issue in the way files with CRLF line terminators are loaded into text buffers in meld. When such a terminator appears exactly at the 4kb boundary an extra empty line will be inserted as 2 characters the terminator consists of are inserted separately. To reproduce the issue: - run "meld msgdialog.c msgdialog.c" (msgdialog.c attached) - go to line 833 and see a superfluous empty line - change any line after 833 e.g. 840 - see incorrect highlighting
The attached patch fixes the issue by changing the way files are loaded into text buffer. This is the simplest fix. If for some reason partial inserts should not be removed then I will try to provide a more complex patch (ring buffer + checking characters at the end of the buffer) Regards, Piotr
From 445e20d432bc6a036537816314007420c2498e19 Mon Sep 17 00:00:00 2001 From: Piotr Piastucki <[email protected]> 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
msgdialog.c.tar.gz
Description: GNU Zip compressed data
_______________________________________________ meld-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/meld-list
