[quote=“MarkVilla”]You are right, but as far as I know, that only works when you can that command from a .sublime-menu entry.
If you try to bind it to a .sublime-keymap shortcut, the array is always empty.[/quote]
Then give your command the logic to determine how its been launched. If you get a non empty paths array, you know you are probably getting the call from the sidebar menu and you can use the array, if you get a group and index, you are probably getting a call from a tab context menu and can select the view at the group and index and get the required info from the view, if you get none of those, then you probably are getting the call from either a view context menu, command palette, or keymap so you can just call active_view from the window object to get the view and get the info you need. I actually do this in some of my plugins.
[pre=#FAFDFF] def run(self, external=False, paths=], group=-1, index=-1):
self.external = external
self.set_view(paths, group, index)
…
def set_view(self, paths, group=-1, index=-1, open_file=True):
if len(paths):
file_path = get_target(paths)
if file_path is None:
return
if open_file:
self.view = self.window.open_file(file_path)
elif index != -1:
self.view = get_group_view(self.window, group, index)
else:
self.view = self.window.active_view()[/pre]