Hi - I need to write a command that can access the self.view.sel() object when a command is invoked from the Find Panel. Eventually the plugin will save the current selection, execute a search and do some things with those selected search results, and then it will restore the previously saved selection. I have everything working when I invoke the command hotkey from the Editor, but it breaks when I invoke the command hotkey from the Find Panel.
I found the problem is due to being unable to get the Editor self.view.sel() object when the hotkey command is invoked from the Find Panel. Here is what I have boiled it down to and I am hoping someone can help.
[code]{ “keys”: “f5”], “command”: “modify_selection_from_findpanel” },
import sublime, sublime_plugin
class ModifySelectionFromFindpanelCommand(sublime_plugin.TextCommand):
def run(self, edit):
print("SELF.VIEW IS: " + str(self.view))
print("SELF.VIEW.WINDOW().VIEWS() IS: " + str(self.view.window().views()))
print("SUBLIME.WINDOWS() IS: " + str(sublime.windows()))
print("SUBLIME.ACTIVE_WINDOW().VIEWS() IS: " + str(sublime.active_window().views()))
print("SUBLIME.ACTIVE_WINDOW().ACTIVE_VIEW() IS: " + str(sublime.active_window().active_view()))
self.view.sel().clear()[/code]
When I push F5 when focused inside the Editor - it works and the selection is removed. However when I push F5 when in the find panel - self.view is a different object. I have tried sublime.active_window().active_view() and also self.view.window().active_view() but neither is able to give me the view object of the main editor window through which I can access sel(). How can I access sel() from a hotkey command invoked from the find panel?
When I push F5 when in the Editor, the Console shows:
SELF.VIEW IS: <sublime.View object at 0x0143B6B0>
SELF.VIEW.WINDOW().VIEWS() IS: <sublime.View object at 0x0165A310>, <sublime.View object at 0x0165A8F0>]
SUBLIME.WINDOWS() IS: <sublime.Window object at 0x0165A930>]
SUBLIME.ACTIVE_WINDOW().VIEWS() IS: <sublime.View object at 0x0165A8F0>, <sublime.View object at 0x0165A3D0>]
SUBLIME.ACTIVE_WINDOW().ACTIVE_VIEW() IS: <sublime.View object at 0x0165A970>
When I push F5 when in the Find Panel, the Console shows:
SELF.VIEW IS: <sublime.View object at 0x0165ABF0>
SELF.VIEW.WINDOW().VIEWS() IS: <sublime.View object at 0x01669270>, <sublime.View object at 0x016692B0>]
SUBLIME.WINDOWS() IS: <sublime.Window object at 0x01669290>]
SUBLIME.ACTIVE_WINDOW().VIEWS() IS: <sublime.View object at 0x016692B0>, <sublime.View object at 0x01669230>]
SUBLIME.ACTIVE_WINDOW().ACTIVE_VIEW() IS: <sublime.View object at 0x016692D0>
I need to get <sublime.View object at 0x0143B6B0> when self.view=<sublime.View object at 0x0165ABF0> but I cannot find <sublime.View object at 0x0143B6B0> showing up in any accessible object???