Skip to content

Commit f568e93

Browse files
authored
Merge pull request #50 from ice9js/feature/case-insensitive-search
Add an option to toggle case sensitivity on and off
2 parents 909c53b + 1a4dd38 commit f568e93

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

AceJump.sublime-settings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
// Syntax highlighting scope for the labels
66
"labels_scope": "invalid",
77

8+
// Toggles case sensitive search in word and character modes.
9+
"search_case_sensitivity": true,
10+
811
// View settings that should be respected when switching the syntax
912
// highlighting mode. In case a plugin you use adds a new
1013
// setting to a view, you probably want to add it to this list.

ace_jump.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def run(self, current_buffer_only = False):
9595
"labels",
9696
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
9797
)
98+
self.case_sensitivity = settings.get("search_case_sensitivity", True)
9899

99100
self.view_settings = settings.get("view_settings", [])
100101
self.view_values = get_views_settings(
@@ -164,7 +165,8 @@ def add_labels(self, regex):
164165
view.run_command("add_ace_jump_labels", {
165166
"regex": regex,
166167
"labels": self.labels,
167-
"highlight": self.highlight
168+
"highlight": self.highlight,
169+
"case_sensitive": self.case_sensitivity
168170
})
169171
self.breakpoints.append(last_index)
170172
self.changed_views.append(view)
@@ -312,16 +314,16 @@ def run(self):
312314
class AddAceJumpLabelsCommand(sublime_plugin.TextCommand):
313315
"""Command for adding labels to the views"""
314316

315-
def run(self, edit, regex, labels, highlight):
317+
def run(self, edit, regex, labels, highlight, case_sensitive):
316318
global hints
317319

318-
characters = self.find(regex, len(labels))
320+
characters = self.find(regex, len(labels), case_sensitive)
319321
self.add_labels(edit, characters, labels)
320322
self.view.add_regions("ace_jump_hints", characters, highlight)
321323

322324
hints = hints + characters
323325

324-
def find(self, regex, max_labels):
326+
def find(self, regex, max_labels, case_sensitive):
325327
"""Returns a list with all occurences matching the regex"""
326328

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

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

338340
if not word:
339341
break

0 commit comments

Comments
 (0)