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

Commit c333798

Browse files
committed
add memory of last selected result
If you re-run the same search twice, the results panel will remember which result you chose the first time and start you hovering over that result the second time.
1 parent 66831e8 commit c333798

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

search_in_project.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class SearchInProjectCommand(sublime_plugin.WindowCommand):
3636
def __init__(self, window):
3737
sublime_plugin.WindowCommand.__init__(self, window)
3838
self.last_search_string = ''
39-
pass
39+
self.last_selected_result_index = 0
4040

4141
def run(self, type="search"):
4242
if type == "search":
@@ -62,6 +62,8 @@ def perform_search(self, text):
6262
if not text:
6363
return
6464

65+
if self.last_search_string != text:
66+
self.last_selected_result_index = 0
6567
self.last_search_string = text
6668
folders = self.search_folders()
6769

@@ -76,7 +78,7 @@ def perform_search(self, text):
7678
self.results,
7779
self.goto_result,
7880
flags,
79-
0,
81+
self.last_selected_result_index,
8082
self.on_highlighted)
8183
else:
8284
self.results = []
@@ -86,6 +88,7 @@ def perform_search(self, text):
8688
sublime.error_message("%s running search engine %s:"%(e.__class__.__name__,self.engine_name) + "\n" + str(e))
8789

8890
def on_highlighted(self, file_no):
91+
self.last_selected_result_index = file_no
8992
if file_no != -1 and file_no != len(self.results) - 1: # last result is "list in view"
9093
file_name_and_col = self.common_path.replace('\"', '') + self.results[file_no][0]
9194
view = self.window.open_file(file_name_and_col, sublime.ENCODED_POSITION | sublime.TRANSIENT)

0 commit comments

Comments
 (0)