@@ -35,6 +35,7 @@ class SearchInProjectCommand(sublime_plugin.WindowCommand):
3535
3636 def __init__ (self , window ):
3737 sublime_plugin .WindowCommand .__init__ (self , window )
38+ self .results = []
3839 self .last_search_string = ''
3940 self .last_selected_result_index = 0
4041
@@ -56,6 +57,10 @@ def run(self, type="search"):
5657 panel_view .run_command ("select_all" )
5758 elif type == "clear" :
5859 self .clear_markup ()
60+ elif type == "next" :
61+ self .goto_relative_result (1 )
62+ elif type == "prev" :
63+ self .goto_relative_result (- 1 )
5964 else :
6065 raise Exception ("unrecognized type \" %s\" " % type )
6166
@@ -104,6 +109,13 @@ def goto_result(self, file_no):
104109 regions = view .find_all (self .last_search_string , sublime .IGNORECASE )
105110 view .add_regions ("search_in_project" , regions , "entity.name.filename.find-in-files" , "circle" , sublime .DRAW_OUTLINED )
106111
112+ def goto_relative_result (self , offset ):
113+ if self .last_search_string :
114+ new_index = self .last_selected_result_index + offset
115+ if 0 <= new_index < len (self .results ) - 1 : # last result is "list in view"
116+ self .last_selected_result_index = new_index
117+ self .goto_result (new_index )
118+
107119 def clear_markup (self ):
108120 for result in self .results [:- 1 ]: # every result except the last one (the "list in view")
109121 file_name_and_col = self .common_path .replace ('\" ' , '' ) + result [0 ]
0 commit comments