11# -*- encoding: utf-8 -*-
22import os
3- import imp
43import sys
54
65import sublime
76import sublime_plugin
87
8+ # Clear module cache to force reloading all modules of this package.
9+ prefix = __package__ + "." # don't clear the base package
10+ for module_name in [
11+ module_name
12+ for module_name in sys .modules
13+ if module_name .startswith (prefix ) and module_name != __name__
14+ ]:
15+ del sys .modules [module_name ]
16+ prefix = None
17+
918from .libs .sublimefunctions import *
1019from .commands .copy import FmCopyCommand
1120from .commands .create import FmCreaterCommand , FmCreateCommand
2130from .commands .open_terminal import FmOpenTerminalCommand
2231from .commands .rename import FmRenameCommand , FmRenamePathCommand
2332
24- BASE_NAME = os .path .dirname (__file__ )
25-
26-
27- def _reload (file ):
28- if file .endswith (".pyc" ):
29- file = file [:- 1 ]
30- file = file [:- 3 ]
31- module = sys .modules .get (file .replace (os .path .sep , "." ))
32- if module :
33- imp .reload (module )
34-
35-
36- # auto reload sub files - for dev
37-
3833
3934def plugin_loaded ():
4035 settings = get_settings ()
@@ -58,21 +53,6 @@ def plugin_loaded():
5853 )
5954
6055
61- class FmDevListener (sublime_plugin .EventListener ):
62- def on_post_save (self , view ):
63- """Reload FileManager
64- To use this, you need to have this plugin:
65- https://github.com/math2001/sublime-plugin-reloader"""
66- if not (
67- os .path .dirname (__file__ ) in view .file_name ()
68- and view .file_name ().endswith (".py" )
69- ):
70- return
71- sublime .run_command (
72- "reload_plugin" , {"main" : __file__ , "folders" : ["commands" , "libs" ],},
73- )
74-
75-
7656class FmEditReplace (sublime_plugin .TextCommand ):
7757 def run (self , edit , ** kwargs ):
7858 kwargs .get ("view" , self .view ).replace (
0 commit comments