diff --git a/colorcoder.py b/colorcoder.py index c917830..178cac6 100644 --- a/colorcoder.py +++ b/colorcoder.py @@ -82,18 +82,18 @@ def on_load(self,view): view.settings().set('colorcode',False) return - self.on_modified_async(view) + self.on_modified(view) def on_post_save(self,view): self.on_load(view) - def on_modified_async(self, view): + def on_modified(self, view): global use_textcommand if view.settings().get('colorcode',False) or view.settings().get('forcecolorcode',False): if use_textcommand: - view.run_command("colorcode") + sublime.set_timeout(lambda: view.run_command("colorcode"), 0) else: - colorcoder.colorcode(view) + sublime.set_timeout(lambda: colorcoder.colorcode(view), 0) @staticmethod def update_scopes(): @@ -105,10 +105,6 @@ def update_use_textcommand(): global use_textcommand use_textcommand = sublime.load_settings("colorcoder.sublime-settings").get('use_fast_highlighting_but_undo_typing_letterwise') - def on_post_text_command(self, view, cmd, args): - if cmd=="set_file_type": - self.on_modified_async(sublime.active_window().active_view()) - @staticmethod def colorcode(view): global hasher, scopes @@ -122,7 +118,7 @@ def colorcode(view): regs[hex(hasher.crc(view.substr(r)))].append(r) for key in regs: - view.add_regions('cc'+key,regs[key],'cc'+key,'', sublime.DRAW_NO_OUTLINE ) + view.add_regions('cc'+key,regs[key],'cc'+key ) del regs @@ -194,7 +190,8 @@ def modify_color_scheme(l,s,read_original = False): modification_running = True name = sublime.load_settings("Preferences.sublime-settings").get("original_color_scheme") if read_original else sublime.active_window().active_view().settings().get('color_scheme') try: - cs = plistlib.readPlistFromBytes(sublime.load_binary_resource(name)) + pp = re.sub(r'\\','/',sublime.packages_path()) + cs = plistlib.readPlist(re.sub(r'^Packages',pp,name)) tokenclr = "#000000" for rule in cs["settings"]: @@ -265,3 +262,5 @@ def plugin_loaded(): for view in wnd.views(): view.settings().set('colorcode',True) view.run_command("colorcode") + +plugin_loaded()