Skip to content
This repository was archived by the owner on Jan 27, 2023. It is now read-only.

Commit 2cece6c

Browse files
make it possible to repeat searches
1 parent 6117f53 commit 2cece6c

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ Copy the folder into the Packages folder.
2121
* Enter the search query; **the query is passed directly to the shell command.** You are responsible for escaping the query, but on the up side you can specify any command line options to go with it. This plugin doesn't make an effort to abstract you away from search tools, but provides a convenient way of running them from Sublime Text 2 instead.
2222
* Hit `Enter` (`Return`). In a short while you'll be presented with a "quck select" panel with the search results. Select any file from that panel (it supports fuzzy searching) to go to the match.
2323

24-
Tip: If you select text and then run Search In Project, it will pre-fill the search string with the selection text; for example, to search for a word project-wide, do `⌘D, ⌘⌥⇧F, ↩`
24+
If you select text and then run Search In Project, it will pre-fill the search string with the selection text; for example, to search for a word project-wide, do `⌘D, ⌘⌥⇧F, ↩`
25+
26+
If you run Search In Project again, it will remember the last search string, so the next search is just an `` away.
2527

2628
## Configuration
2729

search_in_project.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

88

99
class SearchInProjectCommand(sublime_plugin.WindowCommand):
10+
def __init__(self, window):
11+
sublime_plugin.WindowCommand.__init__(self, window)
12+
self.last_search_string = ''
13+
pass
14+
1015
def run(self):
1116
self.settings = sublime.load_settings('SearchInProject.sublime-settings')
1217
self.engine_name = self.settings.get("search_in_project_engine")
@@ -19,16 +24,16 @@ def run(self):
1924
selection_text = view.substr(view.sel()[0])
2025
self.window.show_input_panel(
2126
"Search in project:",
22-
selection_text,
27+
selection_text or self.last_search_string,
2328
self.perform_search, None, None)
2429
pass
2530

2631
def perform_search(self, text):
27-
self.search_string = text
32+
self.last_search_string = text
2833
folders = self.search_folders()
2934

3035
self.common_path = self.find_common_path(folders)
31-
self.results = self.engine.run(self.search_string, folders)
36+
self.results = self.engine.run(text, folders)
3237
if self.results:
3338
self.results = [[result[0].replace(self.common_path, ''), result[1]] for result in self.results]
3439
self.window.show_quick_panel(self.results, self.goto_result)

0 commit comments

Comments
 (0)