Skip to content

Commit

Permalink
refactor: use list-of-strings style "selectors"
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Cherng <[email protected]>
  • Loading branch information
jfcherng committed Nov 1, 2020
1 parent 34842ae commit 54a6852
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
23 changes: 21 additions & 2 deletions HyperClick.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,27 @@
"annotation_not_found_text": "×",
"annotations_enabled": true,

// HyperClick is enabled when the current scope matches this selector
"selector": "source.js,source.ts,source.sass,source.scss,source.less,embedding.php,source.stylus,text.html,source.jstl,source.css,text.pug,source.sugarss,text.sugarml,source.nunjucks,source.jinja2,text.html.twig,source.dart,text.html.smarty",
// HyperClick is enabled when the current scope matches any of selectors
"selectors": [
"embedding.php",
"source.css",
"source.dart",
"source.jinja2",
"source.js",
"source.jstl",
"source.less",
"source.nunjucks",
"source.sass",
"source.scss",
"source.stylus",
"source.sugarss",
"source.ts",
"text.html",
"text.html.smarty",
"text.html.twig",
"text.pug",
"text.sugarml",
],

// Supported languages
// - each has at least a regex to match import statements
Expand Down
6 changes: 6 additions & 0 deletions hyper_click_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@ def is_valid_line(self, line_content):

def is_visible(self, event=None):
view = self.view

# old style discouraged single-string selector
selector = self.settings.get('selector')
if not selector:
# new style list of strings selectors
selector = "(" + ")|(".join(self.settings.get('selectors')) + ")"

if not view.match_selector(view.sel()[0].a, selector):
return False
else:
Expand Down

0 comments on commit 54a6852

Please sign in to comment.