As silly as the below example might seem, it’s just a stripped down version of what I would love to achieve: writing user input into the editor window.
class MyDialogCommand(sublime_plugin.TextCommand):
def run(self, edit):
selection = self.view.substr(sublime.Region(0, self.view.size()))
# self.view.window().run_command('hide_panel');
self.view.window().show_input_panel("Replace selection:", selection, self.on_done, None, None)
def on_done(self, user_input):
sublime.status_message("Hello: " + user_input)
selection = sublime.Region(0, self.view.size())
self.view.replace(edit, selection, user_input)
I have tried many variations (working with global vars, splitting the on_done function into multiple), but none allowed me to achieve my goal. In pretty much every case I ended up with the following error:
TypeError: replace() missing 1 required positional argument: 'edit'
Is there some limitation that does not allow me to this? Is this possible? What am I doing wrong? (Yeah, I’m not a Python guy)