Skip to content

Commit

Permalink
Removed version dependent code.
Browse files Browse the repository at this point in the history
  • Loading branch information
tarwich committed Oct 30, 2013
1 parent 3e637a8 commit aa8423a
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions SelectByRegexCommand.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import re, sublime, sublime_plugin

# Take note if we're in ST3 so that we can do ST3 specific stuff
# (Currently unused, this line is left in, because I think it's handy to have around)
ST3 = sublime.version() >= '3000'

class SelectByRegexCommand(sublime_plugin.TextCommand):
Expand Down Expand Up @@ -84,7 +87,6 @@ def update_selection(self, regex, draw_borders=True):
:param regex: The regular expression for which to search
"""
# TODO: Remove this line
# Don't process empty searches
if not regex: return
# Cache view for speed
Expand Down Expand Up @@ -123,14 +125,10 @@ def update_selection(self, regex, draw_borders=True):
# Erase the borders and select the regions
else: view.erase_regions("SelectByRegexCommand")
else:
# Select the new regions
if len(new_regions):
if ST3:
view.sel().add_all(new_regions)
else:
for r in new_regions:
view.sel().add(r)

# Skip empty regions, because that would empty the selection (annoying)
if len(new_regions):
# Add each selection to the view
for region in new_regions: view.sel().add(region)
# If not regions, then select the original regions
else: view.sel().add_all(SelectByRegexCommand.original_regions)
# Erase the borders and select the regions
Expand Down

0 comments on commit aa8423a

Please sign in to comment.