Skip to content

Commit

Permalink
Merge pull request #51 from ice9js/fix/overlapping-commands
Browse files Browse the repository at this point in the history
Ensure AceJump commands can only be activated one at a time
  • Loading branch information
ice9js authored Oct 11, 2016
2 parents e79d42f + 244679d commit bcb414f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions ace_jump.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

mode = 0

ace_jump_active = False

def get_active_views(window, current_buffer_only):
"""Returns all currently visible views"""

Expand Down Expand Up @@ -73,6 +75,9 @@ class AceJumpCommand(sublime_plugin.WindowCommand):
"""Base command class for AceJump plugin"""

def run(self, current_buffer_only = False):
global ace_jump_active
ace_jump_active = True

self.char = ""
self.target = ""
self.views = []
Expand All @@ -99,6 +104,10 @@ def run(self, current_buffer_only = False):

self.show_prompt(self.prompt(), self.init_value())

def is_enabled(self):
global ace_jump_active
return not ace_jump_active

def show_prompt(self, title, value):
"""Shows a prompt with the given title and value in the window"""

Expand Down Expand Up @@ -128,8 +137,7 @@ def on_input(self, command):

def submit(self):
"""Handles the behavior after closing the prompt"""

global next_search, mode
global next_search, mode, ace_jump_active
next_search = False

self.remove_labels()
Expand All @@ -138,6 +146,7 @@ def submit(self):
self.jump(self.labels.find(self.target))

mode = 0
ace_jump_active = False

def add_labels(self, regex):
"""Adds labels to characters matching the regex"""
Expand Down

0 comments on commit bcb414f

Please # to comment.