Commits

Thejesh GN committed ee7cec5

fixed bugs related to null value of self.window

  • Participants
  • Parent commits 19bc52c

Comments (0)

Files changed (1)

         sublime_plugin.TextCommand.__init__(self, view)
         if self.view.window():
             self.window = self.view.window()
+        elif sublime.active_window():
+            self.window = sublime.active_window()
+
 
     def is_enabled(self):
         # First, is this actually a file on the file system?
         if self.view.file_name() and len(self.view.file_name()) > 0:
             return hg_root(self.get_file_location())
 
+    def get_window(self):
+        return self.view.window() or sublime.active_window()
+
 class HgWindowCommand(HgCommand, sublime_plugin.WindowCommand):
     def __init__(self, window):
         sublime_plugin.WindowCommand.__init__(self, window)
 
 class HgCustomCommand(HgTextCommand):
     def run(self, edit):
-        self.window.show_input_panel("Hg", "",
+        self.get_window().show_input_panel("Hg", "",
             self.on_done, None, None)
 
     def on_done(self, command):
 
     def log_done(self, result):
         self.results = [r.strip().split("\n") for r in result.strip().split('\n\n')]
-        self.window.show_quick_panel(self.results, self.panel_done)
+        self.get_window().show_quick_panel(self.results, self.panel_done)
 
     def panel_done(self, picked):
         if picked == -1:
 
 class HgCommitCommand(HgTextCommand):
     def run(self, edit):
-        self.window.show_input_panel("Message", "", self.on_input, None, None)
+        self.get_window().show_input_panel("Message", "", self.on_input, None, None)
 
     def on_input(self, message):
         if message.strip() == "":
         self.run_command([get_hg(self.view), 'status',], self.status_done)
     def status_done(self, result):
         self.results = filter(self.status_filter, result.rstrip().split('\n'))
-        self.window.show_quick_panel(self.results, self.panel_done, sublime.MONOSPACE_FONT)
+        self.get_window().show_quick_panel(self.results, self.panel_done, sublime.MONOSPACE_FONT)
     def status_filter(self, item):
         # for this class we don't actually care
         return True
         self.run_command([get_hg(self.view), 'branches'], self.branch_done)
     def branch_done(self, result):
         self.results = result.rstrip().split('\n')
-        self.window.show_quick_panel(self.results, self.panel_done, sublime.MONOSPACE_FONT)
+        self.get_window().show_quick_panel(self.results, self.panel_done, sublime.MONOSPACE_FONT)
     def panel_done(self, picked):
         if picked == -1:
             return