Danila Ermolchev Danila Ermolchev - 10 days ago 5
Python Question

sublime plugin. show find-panel and paste text

I need to get string from clipboard, then make with it some manipulations, run default find-panel and paste the string into this.

class ExampleCommand(sublime_plugin.TextCommand):
def run(self, edit):
s = sublime.get_clipboard()
try:
s = s[:s.index('\n')]
except:
pass
self.view.run_command('show_panel', *args* )
self.view.run_command('paste')


In args I tried various interpretations of writing this snippet:

"args": {"panel": "find", "reverse": false} },

Answer

The show_panel command is a WindowCommand, so it can't be executed using view.run_command.

Instead, you must use the window reference:

window.run_command('show_panel', { 'panel': 'find' })

i.e. to get the window from your view:

self.view.window().run_command('show_panel')

The arguments parameter needs to be a dictionary of arguments.

args = dict()
args['panel'] = 'find'

or

args = {"panel": "find", "reverse": False}

self.view.window().run_command('show_panel', args)