Skip to content

Commit

Permalink
Guard against active_view() returning None
Browse files Browse the repository at this point in the history
  • Loading branch information
kaste committed May 11, 2018
1 parent f4be97d commit 8545a27
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
4 changes: 2 additions & 2 deletions busy_indicator_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def on_begin_linting(buffer_id):
State['running'][buffer_id] = time.time()

active_view = State['active_view']
if active_view.buffer_id() == buffer_id:
if active_view and active_view.buffer_id() == buffer_id:
sublime.set_timeout_async(lambda: draw(**State), INITIAL_DELAY * 1000)


Expand All @@ -45,7 +45,7 @@ def on_finished_linting(buffer_id, **kwargs):
State['running'].pop(buffer_id, None)

active_view = State['active_view']
if active_view.buffer_id() == buffer_id:
if active_view and active_view.buffer_id() == buffer_id:
draw(**State)


Expand Down
4 changes: 3 additions & 1 deletion goto_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

class SublimeLinterGotoError(sublime_plugin.WindowCommand):
def run(self, direction='next', count=1, wrap=False):
goto(self.window.active_view(), direction, count, wrap)
active_view = self.window.active_view()
if active_view:
goto(active_view, direction, count, wrap)


def goto(view, direction, count, wrap):
Expand Down
8 changes: 7 additions & 1 deletion highlight_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ def toggle_demoted_regions(view, show):
class SublimeLinterToggleHighlights(sublime_plugin.WindowCommand):
def run(self):
view = self.window.active_view()
if not view:
return

vid = view.id()
hidden = vid in State['quiet_views']
if hidden:
Expand Down Expand Up @@ -625,8 +628,11 @@ def on_hover(self, view, point, hover_zone):
class SublimeLinterLineReportCommand(sublime_plugin.WindowCommand):
def run(self):
view = self.window.active_view()
if not view:
return

point = view.sel()[0].begin()
open_tooltip(self.window.active_view(), point, line_report=True)
open_tooltip(view, point, line_report=True)


TOOLTIP_STYLES = '''
Expand Down
4 changes: 2 additions & 2 deletions status_bar_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def plugin_unloaded():
@events.on(events.LINT_RESULT)
def on_lint_result(buffer_id, **kwargs):
active_view = State['active_view']
if active_view.buffer_id() == buffer_id:
if active_view and active_view.buffer_id() == buffer_id:
draw(**State)


Expand All @@ -51,7 +51,7 @@ def on_selection_modified_async(self, view):
active_view = State['active_view']
# It is possible that views (e.g. panels) update in the background.
# So we check here and return early.
if active_view.buffer_id() != view.buffer_id():
if not active_view or active_view.buffer_id() != view.buffer_id():
return

current_pos = get_current_pos(active_view)
Expand Down
3 changes: 2 additions & 1 deletion sublime_linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ def visible_views():

# Priority for the active view
active_view = window.active_view()
yield active_view
if active_view:
yield active_view

num_groups = window.num_groups()
for group_id in range(num_groups):
Expand Down

0 comments on commit 8545a27

Please sign in to comment.