def reassign(self, view): v = view.settings() v.clear_on_change("checkbounce_spelling_monitor") on = v.get("enable_checkbounce_spelling") vid = view.id() if not vid in self.prev_syntax: self.prev_syntax[vid] = v.get("syntax") elif self.prev_syntax[vid] != v.get("syntax"): SpellChecker.remove(view.id()) view.erase_status('checkbounce') SpellChecker.assign(view, self.finish) if on != self.on: self.on = on SpellChecker.remove(vid) sublime.set_timeout(lambda: view.erase_status('checkbounce'), 0) if on: SpellChecker.assign(view, self.finish) SpellChecker.reload() if not on: if vid in self.loaded: self.loaded.remove(vid) if vid in self.checked: self.checked.remove(vid) self.on_modified(view) v.add_on_change('checkbounce_spelling_monitor', lambda: self.reassign(view))
def run(self, edit): SpellChecker.reload() try: errs = const.spell_error_regions[self.view.id()] except KeyError: sublime.status_message("Document has not been checked.") return errs = sorted(errs, key=lambda e: e.a) try: self.checker = SpellChecker.get_checker(self.view.id()) except KeyError: sublime.status_message("Document has not been checked.") return if self.checker.orthography.dominantLanguage() == "und": sublime.status_message("Language could not be determined.") return if not len(errs): sublime.status_message("No errors!") return self.offset = 0 self.reset = 0 self.i = 0 self.forward = True self.ignored = [] pos = self.view.sel()[0].a # self.view.sel().clear() start = 0 for j in range(len(errs)): if errs[j].contains(pos): start = j break b = errs[j].b try: x = errs[j + 1].a except IndexError: break if b < pos < x: start = j + 1 break self.start = start end_chunk = errs[start:] beginning_chunk = errs[:start] self.chunks = [] if not beginning_chunk == end_chunk: self.chunks.extend(end_chunk) self.chunks.extend(beginning_chunk) else: self.chunks = errs self.get_next_error(0, next=False)
def hit(self, view): if not ST3: self.check(view.id()) self.checked.add(view.id()) if view.size() == 0: c = SpellChecker.get_checker(view.id()) if c: c.clear() SpellChecker.reload() sublime.set_timeout(lambda: view.erase_status('checkbounce'), 0) return const.spell_queue.hit(view)