[gedit] [externaltools] Fix running tool without open documents



commit 194ac50c4cf26d2e30d6f9f2717473773816cf37
Author: Jesse van den Kieboom <jessevdk gnome org>
Date:   Sun Sep 14 13:22:52 2014 +0200

    [externaltools] Fix running tool without open documents
    
    https://bugzilla.gnome.org/show_bug.cgi?id=736574

 plugins/externaltools/tools/functions.py |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/plugins/externaltools/tools/functions.py b/plugins/externaltools/tools/functions.py
index ba0960a..f4d1ab5 100644
--- a/plugins/externaltools/tools/functions.py
+++ b/plugins/externaltools/tools/functions.py
@@ -69,6 +69,8 @@ def run_external_tool(window, panel, node):
     capture.set_env(GEDIT_CWD=cwd)
 
     view = window.get_active_view()
+    document = None
+
     if view is not None:
         # Environment vars relative to current document
         document = view.get_buffer()
@@ -224,7 +226,9 @@ def run_external_tool(window, panel, node):
             capture.connect('stdout-line', capture_stdout_line_document, document, pos)
     elif output_type != 'nothing':
         capture.connect('stdout-line', capture_stdout_line_panel, panel)
-        document.begin_user_action()
+
+        if not document is None:
+            document.begin_user_action()
 
     capture.connect('stderr-line', capture_stderr_line_panel, panel)
     capture.connect('begin-execute', capture_begin_execute_panel, panel, view, node.name)
@@ -234,8 +238,8 @@ def run_external_tool(window, panel, node):
     capture.execute()
 
     if output_type != 'nothing':
-        document.end_user_action()
-
+        if not document is None:
+            document.end_user_action()
 
 class MultipleDocumentsSaver:
     def __init__(self, window, panel, all_docs, node):


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