Home Download Buy Blog Forum Support

Little help with show_input_panel

Little help with show_input_panel

Postby iamntz on Thu May 09, 2013 2:06 pm

Hi guys. So, i have this small plugin that replace # chars with numbers. The problem is that it never worked on ST3 and today i decided to allocate some time to fix it.

Here is the full code: https://gist.github.com/iamntz/5546478

So, when i run the command, i get this error raised:

Code: Select all
ValueError: Edit objects may not be used after the TextCommand's run method has returned

There is some weird issue on this code:

Code: Select all
window.show_input_panel('Count Start:Step', '1:1', countThoseSelections, False, False)

Because if i eliminate that and i just call the countThoseSelections('1:1') method it just works. Also, params is sent to this method by show_input_panel.

I'm kinda out of ideas. Any help would be appreciated. Thanks!
Posts: 1035
Joined: Fri Apr 29, 2011 8:52 am
Location: Romania

Re: Little help with show_input_panel

Postby skuroda on Thu May 09, 2013 6:12 pm

You lose the edit object when the command returns. You will have to call another command to perform the actual insert. You can use something like

Code: Select all
class BatchReplaceCommand(sublime_plugin.TextCommand):
    def run(self, edit, replace_text, begin_region_point, end_region_point):
        self.view.replace(edit, region, sublime.Region(begin_region_point, end_region_point))

I didn't test that, so you may need to modify it a bit to get it work, but you should be able to get your plugin running.
Posts: 692
Joined: Fri Oct 05, 2012 8:11 am

Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 4 guests