Skip to content

Commit

Permalink
Merge pull request #50 from ice9js/feature/case-insensitive-search
Browse files Browse the repository at this point in the history
Add an option to toggle case sensitivity on and off
  • Loading branch information
ice9js authored Sep 14, 2016
2 parents 909c53b + 1a4dd38 commit f568e93
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
3 changes: 3 additions & 0 deletions AceJump.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
// Syntax highlighting scope for the labels
"labels_scope": "invalid",

// Toggles case sensitive search in word and character modes.
"search_case_sensitivity": true,

// View settings that should be respected when switching the syntax
// highlighting mode. In case a plugin you use adds a new
// setting to a view, you probably want to add it to this list.
Expand Down
12 changes: 7 additions & 5 deletions ace_jump.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def run(self, current_buffer_only = False):
"labels",
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
)
self.case_sensitivity = settings.get("search_case_sensitivity", True)

self.view_settings = settings.get("view_settings", [])
self.view_values = get_views_settings(
Expand Down Expand Up @@ -164,7 +165,8 @@ def add_labels(self, regex):
view.run_command("add_ace_jump_labels", {
"regex": regex,
"labels": self.labels,
"highlight": self.highlight
"highlight": self.highlight,
"case_sensitive": self.case_sensitivity
})
self.breakpoints.append(last_index)
self.changed_views.append(view)
Expand Down Expand Up @@ -312,16 +314,16 @@ def run(self):
class AddAceJumpLabelsCommand(sublime_plugin.TextCommand):
"""Command for adding labels to the views"""

def run(self, edit, regex, labels, highlight):
def run(self, edit, regex, labels, highlight, case_sensitive):
global hints

characters = self.find(regex, len(labels))
characters = self.find(regex, len(labels), case_sensitive)
self.add_labels(edit, characters, labels)
self.view.add_regions("ace_jump_hints", characters, highlight)

hints = hints + characters

def find(self, regex, max_labels):
def find(self, regex, max_labels, case_sensitive):
"""Returns a list with all occurences matching the regex"""

global next_search, last_index
Expand All @@ -333,7 +335,7 @@ def find(self, regex, max_labels):
last_search = visible_region.end()

while (next_search < last_search and last_index < max_labels):
word = self.view.find(regex, next_search)
word = self.view.find(regex, next_search, 0 if case_sensitive else sublime.IGNORECASE)

if not word:
break
Expand Down

0 comments on commit f568e93

Please # to comment.