Home Download Buy Blog Forum Support

Replacing content of the region that is held in add_regions

Replacing content of the region that is held in add_regions

Postby maximsch2 on Sun Apr 14, 2013 10:13 pm

I am writing a plugin that maintains a set of regions (held by sublime using add_regions function) that I want to sometimes control from the plugin. If I type something inside the region, then that region expands automatically. But it doesn't work like that if I edit it from code. So currently my code looks like this:

Code: Select all
regions = view.get_regions("inb_input")
reg = regions[n]
start = reg.a
end = start + len(new_text)
sview.replace(edit, reg, new_text)
regs = view.get_regions("inb_input")
regs[n] = sublime.Region(start, end)
view.add_regions("inb_input", regs, "string", "", sublime.HIDDEN)


Is there a better way to do it? Shouldn't view.replace keep the region updated inside sublime (in add_regions) by itself (e.g. is there a chance that it will get changed in a later version)?
maximsch2
 
Posts: 5
Joined: Sun Apr 14, 2013 10:02 pm

Return to Plugin Development

Who is online

Users browsing this forum: Exabot [Bot] and 5 guests

cron