Skip to content

Commit

Permalink
Fixed it not working correctly for window panels after workaround
Browse files Browse the repository at this point in the history
from sublimehq/sublime_text#289
Multiple event hooks don't work with clones
  • Loading branch information
evandrocoan committed Jun 21, 2018
1 parent 0b2711c commit a69e69b
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions word_highlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,26 @@ def on_activated(self, view):
view.erase_regions("WordHighlight")

def on_selection_modified(self, view):
view = sublime.active_window().active_view()
if view and Pref.enabled and not view.settings().get('is_widget'):
active_window = sublime.active_window()
panel_has_focus = not view.file_name()

is_widget = view.settings().get('is_widget')
active_panel = active_window.active_panel()

# print( "is_widget:", is_widget )
# print( "panel_has_focus:", panel_has_focus )
if active_panel and panel_has_focus or is_widget:
correct_view = view

else:
correct_view = active_window.active_view()

# print( "correct_view:", correct_view )
if correct_view and Pref.enabled and not is_widget:
now = time.time()
if now - Pref.timing > 0.08:
Pref.timing = now
sublime.set_timeout(lambda:self.highlight_occurences(view), 0)
sublime.set_timeout(lambda:self.highlight_occurences(correct_view), 0)
else:
Pref.timing = now

Expand Down

0 comments on commit a69e69b

Please sign in to comment.