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

Commit 66831e8

Browse files
committed
add file previews on hover
After typing in your search term, the panel of results appears. This panel now shows previews of the result in the background when you hover over each result.
1 parent ddbc4ed commit 66831e8

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

search_in_project.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,24 @@ def perform_search(self, text):
7171
if self.results:
7272
self.results = [[result[0].replace(self.common_path.replace('\"', ''), ''), result[1][:self.MAX_RESULT_LINE_LENGTH]] for result in self.results]
7373
self.results.append("``` List results in view ```")
74-
self.window.show_quick_panel(self.results, self.goto_result)
74+
flags = 0
75+
self.window.show_quick_panel(
76+
self.results,
77+
self.goto_result,
78+
flags,
79+
0,
80+
self.on_highlighted)
7581
else:
7682
self.results = []
7783
sublime.message_dialog('No results')
7884
except Exception as e:
7985
self.results = []
8086
sublime.error_message("%s running search engine %s:"%(e.__class__.__name__,self.engine_name) + "\n" + str(e))
8187

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

8393
def goto_result(self, file_no):
8494
if file_no != -1:

0 commit comments

Comments
 (0)