Sublime Forum

Replacing content of the region that is held in add_regions

#1

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:

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)?

0 Likes