[gedit/gnome-3-10] Actually save the *modified* docs before running a tool



commit e68da1a02a2f21dcc5ee31eac03bb4f851e0d89c
Author: Paolo Borelli <pborelli gnome org>
Date:   Fri Feb 7 09:59:22 2014 +0100

    Actually save the *modified* docs before running a tool
    
    Fixes bug https://bugzilla.gnome.org/show_bug.cgi?id=659437
    Based on the analysis by Andrew Fountain

 plugins/externaltools/tools/functions.py |   16 +++++-----------
 1 files changed, 5 insertions(+), 11 deletions(-)
---
diff --git a/plugins/externaltools/tools/functions.py b/plugins/externaltools/tools/functions.py
index 5fa6a1f..fe4457d 100644
--- a/plugins/externaltools/tools/functions.py
+++ b/plugins/externaltools/tools/functions.py
@@ -244,25 +244,19 @@ class MultipleDocumentsSaver:
         else:
             docs = [window.get_active_document()]
 
-        for i in range(len(docs)):
-            doc = docs[i]
-
-            if doc.get_modified():
-                all_docs = False
-                docs.remove(doc)
-            
+        docs_to_save = [ doc for doc in docs if doc.get_modified() ]
         signals = {}
 
-        for doc in docs:
+        for doc in docs_to_save:
             signals[doc] = doc.connect('saving', self.on_document_saving)
 
-        if all_docs:
+        if len(docs_to_save) == len(docs) and len(docs) != 0:
             Gedit.commands_save_all_documents(window)
         else:
-            for doc in docs:
+            for doc in docs_to_save:
                 Gedit.commands_save_document(window, doc)
 
-        for doc in docs:
+        for doc in docs_to_save:
             doc.disconnect(signals[doc])
 
         self.run_tool()


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