[meld] filediff: Fix check-save workflow when given a list of buffers



commit 4f947506b67f705e3fad8e7a5bfaf3fea46a5598
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Tue Jan 1 10:09:44 2019 +1000

    filediff: Fix check-save workflow when given a list of buffers
    
    This isn't currently used, but it was when we were using
    check_save_modified() for drag-n-drop and file selector save checks.
    The problem was that when actually trying to save we prompted using the
    passed buffer list, but didn't refer to that list when trying to save.

 meld/filediff.py | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index 08f12093..a76a8a93 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -875,16 +875,20 @@ class FileDiff(MeldDoc, Component):
             try_save = [b.get_active() for b in buttons]
             dialog.widget.destroy()
 
-            if response == Gtk.ResponseType.OK and any(try_save):
-                for i in range(self.num_panes):
+            if response == Gtk.ResponseType.OK:
+                for i, buf in enumerate(buffers):
                     if try_save[i]:
-                        self.save_file(i)
-                return Gtk.ResponseType.CANCEL
+                        self.save_file(self.textbuffer.index(buf))
 
-        if response == Gtk.ResponseType.DELETE_EVENT:
-            response = Gtk.ResponseType.CANCEL
-        elif response == Gtk.ResponseType.CLOSE:
-            response = Gtk.ResponseType.OK
+                # Regardless of whether these saves are successful or not,
+                # we return a cancel here, so that other closing logic
+                # doesn't run. Instead, the file-saved callback from
+                # save_file() handles closing files and setting state.
+                return Gtk.ResponseType.CANCEL
+            elif response == Gtk.ResponseType.DELETE_EVENT:
+                response = Gtk.ResponseType.CANCEL
+            elif response == Gtk.ResponseType.CLOSE:
+                response = Gtk.ResponseType.OK
 
         if response == Gtk.ResponseType.OK and self.meta:
             self.prompt_resolve_conflict()


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