[patch] Fix delete and copy up linkmap actions at EOF



Hi,

I've spotted yet another issue with linkmap actions when changes to be applied end at EOF.
Delete action leaves a single blank line and copy up action concatenates lines - see the following screenshot for more details http://piastucki.bdl.pl/meld/patch_eof.png.
Patch attached.

Cheers,
Piotr

From 5b874f7a60336d5c868d83ddb3f71b71fa51d67a Mon Sep 17 00:00:00 2001
From: Piotr Piastucki <leech miranda gmail com>
Date: Mon, 10 Aug 2009 18:16:17 +0200
Subject: [PATCH] Fix delete and copy up linkmap actions at EOF

---
 filediff.py |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/filediff.py b/filediff.py
index 25a5c86..763f5c5 100644
--- a/filediff.py
+++ b/filediff.py
@@ -1343,10 +1343,15 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
                     b0 = self.textbuffer[src]
                     b1 = self.textbuffer[dst]
                     if self.keymask & MASK_SHIFT: # delete
-                        b0.delete(get_iter_at_line_or_eof(b0, chunk[0]), get_iter_at_line_or_eof(b0, chunk[1]))
+                        iter = get_iter_at_line_or_eof(b0, chunk[0]);
+                        if chunk[1] >= b0.get_line_count():
+                            iter.backward_char()
+                        b0.delete(iter, get_iter_at_line_or_eof(b0, chunk[1]))
                     elif self.keymask & MASK_CTRL: # copy up or down
                         t0 = b0.get_text( get_iter_at_line_or_eof(b0, chunk[0]), get_iter_at_line_or_eof(b0, chunk[1]), 0)
                         if event.y - rect[1] < 0.5 * rect[3]: # copy up
+                            if chunk[1] >= b0.get_line_count() and chunk[2] < b1.get_line_count():
+                                t0 = t0 + "\n"
                             insert_with_tags_by_name(b1, chunk[2], t0, "edited line")
                         else: # copy down
                             insert_with_tags_by_name(b1, chunk[3], t0, "edited line")
-- 
1.6.0.4



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]