From e777ebc0d8cd454971f7cad94b919ad0408fe3fb Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Fri, 13 Oct 2017 11:22:02 -0300 Subject: [PATCH] Attempt to fix AttributeError: 'NoneType' object has no attribute 'views'. Issue: https://github.com/aziz/SublimeANSI/issues/43 --- ansi.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ansi.py b/ansi.py index b10ede3..8d93073 100644 --- a/ansi.py +++ b/ansi.py @@ -293,6 +293,8 @@ def detect_left_ansi(self, view): sublime.set_timeout_async(partial(self.check_left_ansi, view), 50) def check_left_ansi(self, view): + if not view: + return if not self._is_view_valid(view): self._del_event_listeners(view) return @@ -323,11 +325,13 @@ def detect_syntax_change(self, view): view.window().run_command("undo_ansi") def _is_view_valid(self, view): - if view.window() is None: + window = view.window() + + if window is None: return False - if view.window() not in sublime.windows(): + if window not in sublime.windows(): return False - if view not in view.window().views(): + if view not in window.views(): return False return True