def run(self, edit): self.items = [] self.regions = [] self.regions = self.view.find_all(self.pattern) self.items = [mw.strunquote(self.get_header(x)) for x in self.regions] if self.items: sublime.set_timeout(lambda: self.view.window().show_quick_panel(self.items, self.on_select), 1) else: sublime.status_message('No internal links was found.')
def prepare_header(self, header): maxlen = 70 link_url = mw.strunquote(header.group(1)) link_descr = re.sub(r'<.*?>', '', header.group(2)) postfix = '..' if len(link_descr) > maxlen else '' return '%s: %s%s' % (link_url, link_descr[:maxlen], postfix)