Skip to content

Commit

Permalink
Use Sublime's built-in package ignoring
Browse files Browse the repository at this point in the history
Packages can now be disabled using Sublime Text's built-in
disabling functionality, so remove show_indent_guides setting.
Include new unload_handler and __init__ to make the experience
seamless.
  • Loading branch information
Nikolaus Wittenstein committed Aug 5, 2011
1 parent 1cfdb61 commit 1e5fa2c
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions indent_guides.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
"""
ENABLING GUIDES
"show_indent_guides": true
if you want the guides drawn, add this to your user file preferences.
PLACEMENT OPTIONS
"indent_guides_flush_with_text": true
if you want your guides to be drawn all the way up to the text, add this
Expand Down Expand Up @@ -46,7 +42,21 @@
DEFAULT_COLOR_SCOPE_NAME = "comment"
DEFAULT_MAX_FILE_CHARACTERS = 524288

def unload_handler():
print("unloaded")
for window in sublime.windows():
for view in window.views():
view.erase_regions('IndentGuidesListener')

class IndentGuidesListener(sublime_plugin.EventListener):
def __init__(self):
#Files don't get their guides redrawn until they're activated or loaded,
#so let's generate guides for the front file.
#Views in other groups won't have their guides refreshed, but I don't
#believe it's possible to find the active view in another group without
#switching to that view.
self.refresh(sublime.active_window().active_view(), whole_file=True)

def find_regions_of_interest(self, view, whole_file):
find_str = r"^(( )|(\t))+"
if whole_file:
Expand Down Expand Up @@ -102,8 +112,7 @@ def update_guides(self, view, regions_of_interest, guides):
def refresh(self, view, whole_file=False):
settings = view.settings()

if (not settings.get("show_indent_guides")
or not self.file_is_small_enough(view)):
if (not self.file_is_small_enough(view)):
view.erase_regions('IndentGuidesListener')
return

Expand Down

0 comments on commit 1e5fa2c

Please sign in to comment.