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

Commit 3c69acb

Browse files
committed
add gutter marks while hovering over selections
1 parent 964de16 commit 3c69acb

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

search_in_project.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,26 @@ def perform_search(self, text):
9696
def on_highlighted(self, file_no):
9797
self.last_selected_result_index = file_no
9898
if file_no != -1 and file_no != len(self.results) - 1: # last result is "list in view"
99-
file_name_and_col = self.common_path.replace('\"', '') + self.results[file_no][0]
100-
view = self.window.open_file(file_name_and_col, sublime.ENCODED_POSITION | sublime.TRANSIENT)
99+
self.open_and_highlight_file(file_no, transient=True)
100+
101+
def open_and_highlight_file(self, file_no, transient=False):
102+
file_name_and_col = self.common_path.replace('\"', '') + self.results[file_no][0]
103+
flags = sublime.ENCODED_POSITION
104+
if transient:
105+
flags |= sublime.TRANSIENT
106+
view = self.window.open_file(file_name_and_col, flags)
107+
108+
regions = view.find_all(self.last_search_string, sublime.IGNORECASE)
109+
view.add_regions("search_in_project", regions, "entity.name.filename.find-in-files", "circle", sublime.DRAW_OUTLINED)
101110

102111
def goto_result(self, file_no):
103-
if file_no != -1:
112+
if file_no == -1:
113+
self.clear_markup()
114+
else:
104115
if file_no == len(self.results) - 1: # last result is "list in view"
105116
self.list_in_view()
106117
else:
107-
file_name_and_col = self.common_path.replace('\"', '') + self.results[file_no][0]
108-
view = self.window.open_file(file_name_and_col, sublime.ENCODED_POSITION)
109-
regions = view.find_all(self.last_search_string, sublime.IGNORECASE)
110-
view.add_regions("search_in_project", regions, "entity.name.filename.find-in-files", "circle", sublime.DRAW_OUTLINED)
118+
self.open_and_highlight_file(file_no)
111119

112120
def goto_relative_result(self, offset):
113121
if self.last_search_string:

0 commit comments

Comments
 (0)