Home Download Buy Blog Forum Support

Porting to ST3

Re: Porting to ST3

Postby colinta on Wed Apr 10, 2013 5:17 pm

I think a solution for the common use-case of `begin_edit` would be helpful. `begin_edit` is still really helpful is when using an input panel (async edits). In the example below I'm doing something trivial (and `run_command('insert')` works), but in the plugin I'm porting now I'm manipulating regions and replacing lots of text... non-trivial. My work around is to create a new command, and pass it all the parameters it needs via `run_command`. This is not good clean code, and it's def not an improvement from `try: begin_edit ...finally: end_edit`.

Would this, or something like it, be possible?

Code: Select all
# i don't want to create a new command, so instead...
region = sublime.Region(a, b)
text = 'gonna insert it'
def insert_text(edit):
    self.view.replace(edit, region, text)
run_command(insert_text)
colinta
 
Posts: 14
Joined: Wed Dec 21, 2011 9:43 pm

Re: Porting to ST3

Postby sublimator on Sat Apr 13, 2013 3:12 pm

agree, had same idea myself, think we are on the right track :)
It is better to remain silent and be thought a fool, than to speak out and remove all doubt
sublimator
 
Posts: 649
Joined: Thu Mar 20, 2008 5:41 am

Previous

Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 7 guests