def run(self, edit):
self.window = self.view.window()
v = self.view
if len(v.sel()) != 1:
return
cursor = v.sel()[0].a
line_range = v.line(cursor)
line_content = v.substr(line_range).strip()
matched = self.is_valid_line(line_content)
if matched:
destination_str = matched.group(1)
file_path = HyperClickPathResolver(v,
destination_str,
self.roots, self.lang, self.settings
)
resolved_path = file_path.resolve()
if resolved_path:
if resolved_path.startswith('http://') or resolved_path.startswith('https://'):
webbrowser.open_new_tab(resolved_path)
else:
self.window.open_file(resolved_path)
评论列表
文章目录