def run(self, count=1, mode=None, globally=False):
def f(view, s):
if mode == modes.NORMAL:
return sublime.Region(location, location)
elif mode == modes.VISUAL:
return sublime.Region(s.a + 1, location)
elif mode == modes.INTERNAL_NORMAL:
return sublime.Region(s.a, location)
return s
current_sel = self.view.sel()[0]
self.view.sel().clear()
self.view.sel().add(current_sel)
location = self.find_symbol(current_sel, globally=globally)
if not location:
return
if globally:
# Global symbol; simply open the file; not a motion.
# TODO: Perhaps must be a motion if the target file happens to be
# the current one?
self.view.window().open_file(
location[0] + ':' + ':'.join([str(x) for x in location[2]]),
sublime.ENCODED_POSITION)
return
# Local symbol; select.
location = self.view.text_point(*location)
regions_transformer(self.view, f)
评论列表
文章目录