3
3
# DONE introduce a settings file to get settings from
4
4
# DONE [ST3] use api function (only available in ST3) to get the project name/id (rather than using a hash of the project folders)
5
5
# DONE [ST3] preview the file while cycling through the quick panel history entries
6
- # SONE [ST3] support "quick open" from the quick panel (mapped by default to the "right" key)
6
+ # DONE [ST3] support "quick open" from the quick panel (mapped by default to the "right" key)
7
7
# DONE [ST3] removed unnecessary view settings (and associated code) by listening for the on_pre_close event rather than the on_close event
8
8
# DONE added setting for using monospaced font in the quick panel
9
9
# DONE fixed ST2 support
@@ -41,7 +41,7 @@ def __load_settings(self):
41
41
"""Load the plugin settings from FileHistory.sublime-settings"""
42
42
app_settings = sublime .load_settings (self .SETTINGS_FILE )
43
43
settings_exist = app_settings .has ('history_file' )
44
-
44
+
45
45
self .PRINT_DEBUG = self .__ensure_setting (app_settings , 'debug' , True )
46
46
self .GLOBAL_MAX_ENTRIES = self .__ensure_setting (app_settings , 'global_max_entries' , 100 )
47
47
self .PROJECT_MAX_ENTRIES = self .__ensure_setting (app_settings , 'project_max_entries' , 50 )
@@ -124,9 +124,6 @@ def __save_history(self):
124
124
def get_history (self , current_project_only = True ):
125
125
"""Return the requested history (global or project-specific): closed files followed by opened files"""
126
126
127
- # Set a special setting so we can isolate the context for the quick-open command's keymap entry
128
- self .sublime_settings .set ('file_history_active' , True )
129
-
130
127
# Make sure the history is loaded
131
128
if len (self .history ) == 0 :
132
129
self .__load_history ()
@@ -241,9 +238,6 @@ def __clear_context(self):
241
238
self .current_view = None
242
239
self .current_history_entry = None
243
240
244
- # Remove the special setting (used by the quick-open command)
245
- self .sublime_settings .erase ('file_history_active' )
246
-
247
241
def __track_calling_view (self , window ):
248
242
"""Remember the view that the command was run from (including the group and index positions),
249
243
so we can return to the "calling" view if the user cancels the preview
@@ -258,7 +252,7 @@ def __track_calling_view(self, window):
258
252
else :
259
253
self .calling_view_index = [0 , 0 ]
260
254
self .calling_view_is_empty = True
261
-
255
+
262
256
def __calculate_view_index (self , window , history_entry ):
263
257
# Get the group of the new view (the currently active group is the default)
264
258
group = history_entry ['group' ]
@@ -299,6 +293,14 @@ def preview_history(self, window, history_entry):
299
293
self .__close_preview (window )
300
294
self .__remove_view (filepath , self .get_current_project_key (), True )
301
295
296
+ def on_file_history_open (self ):
297
+ # Set a special setting so we can isolate the context for the quick-open command's keymap entry
298
+ self .sublime_settings .set ('file_history_active' , True )
299
+
300
+ def on_file_history_closed (self ):
301
+ # Remove the special setting that was set when the quick panel was opened
302
+ self .sublime_settings .erase ('file_history_active' )
303
+
302
304
def quick_open_preview (self , window ):
303
305
"""Open the file that is currently being previewed"""
304
306
if not self .current_history_entry : return
@@ -380,6 +382,9 @@ def run(self, show_quick_panel=True, current_project_only=True):
380
382
filepath = node ['filename' ]
381
383
display_list .append ([os .path .basename (filepath ), os .path .dirname (filepath )])
382
384
font_flag = sublime .MONOSPACE_FONT if FileHistory .instance ().USE_MONOSPACE else 0
385
+
386
+ FileHistory .instance ().on_file_history_open ()
387
+
383
388
if is_ST2 :
384
389
self .window .show_quick_panel (display_list , self .open_file , font_flag )
385
390
else :
@@ -396,6 +401,8 @@ def show_preview(self, selected_index):
396
401
FileHistory .instance ().preview_history (self .window , self .history_list [selected_index ])
397
402
398
403
def open_file (self , selected_index ):
404
+ FileHistory .instance ().on_file_history_closed ()
405
+
399
406
if self .is_valid (selected_index ):
400
407
FileHistory .instance ().open_history (self .window , self .history_list [selected_index ])
401
408
else :
0 commit comments