@@ -58,10 +58,9 @@ def record_movement(self, location):
5858
5959 if self ._current :
6060 time_delta = abs (location .time - self ._current .time )
61- print ("time delta is: " + str (time_delta ))
6261 subsume = self ._current .path == location .path and time_delta <= TIME_THRESHOLD
6362 if subsume :
64- print ("nav_history: subsumed current" )
63+ print ("nav_history: subsumed current, time delta is " + str ( time_delta ) )
6564 if self .has_changed (location ):
6665 self ._current = location
6766 self ._last_movement = location .copy ()
@@ -151,14 +150,35 @@ def get_history():
151150 _histories [window_id ] = history = History ()
152151 return history
153152
153+ class PrintNavigationHistory (sublime_plugin .WindowCommand ):
154+ def run (self ):
155+ history = get_history ()
156+ if history is None :
157+ return
158+
159+ print ("=====" )
160+ for entry in history ._back :
161+ print (str (entry .path ) + ":" + str (entry .line ) + ":" + str (entry .col ))
162+ print ("* " + str (history ._current .path ) + ":" + str (history ._current .line ) + ":" + str (history ._current .col ))
163+ for entry in history ._forward :
164+ print (str (entry .path ) + ":" + str (entry .line ) + ":" + str (entry .col ))
165+ print ("=====" )
166+
154167class NavigationHistoryRecorder (sublime_plugin .EventListener ):
155168 """Keep track of history
156169 """
157170
158171 def on_selection_modified (self , view ):
172+ # filters out temporary navs from ctrl+f and ctrl+g
173+ active_view_id = view .window () and view .window ().active_view () and view .window ().active_view ().id ()
174+ if hasattr (self , "_last_activated" ) and self ._last_activated and self ._last_activated != active_view_id :
175+ print ("nav_history: on_selection_modified when an overlay is active, skipped" )
176+ return
177+
159178 self .possiblyRecordMovement (view )
160179
161180 def on_activated (self , view ):
181+ self ._last_activated = view .id ()
162182 self .possiblyRecordMovement (view )
163183
164184 def possiblyRecordMovement (self , view ):
@@ -211,6 +231,7 @@ def run(self, edit):
211231
212232 location = history .back ()
213233 if location :
234+ lock_buffer_scroll ()
214235 print ("back to: " + str (location .path ) + ":" + str (location .line ) + ":" + str (location .col ))
215236
216237 window = sublime .active_window ()
@@ -221,7 +242,6 @@ def run(self, edit):
221242 for view in window .views ():
222243 if view .id () == location .path :
223244 found = True
224- lock_buffer_scroll ()
225245 window .focus_view (view )
226246 pt = view .text_point (location .line , location .col )
227247 view .sel ().clear ()
@@ -243,6 +263,7 @@ def run(self, edit):
243263
244264 location = history .forward ()
245265 if location :
266+ lock_buffer_scroll ()
246267 print ("forward to: " + str (location .path ) + ":" + str (location .line ) + ":" + str (location .col ))
247268
248269 window = sublime .active_window ()
@@ -253,7 +274,6 @@ def run(self, edit):
253274 for view in window .views ():
254275 if view .id () == location .path :
255276 found = True
256- lock_buffer_scroll ()
257277 window .focus_view (view )
258278 pt = view .text_point (location .line , location .col )
259279 view .sel ().clear ()
0 commit comments