Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
get_regions does not work after undo or redo #1121
In theory the following should work, but after doing undo or redo the regions disappears.
v = sublime.active_window().active_view() r = [sublime.Region(s.a, s.b) for s in v.sel()] if r: print('see regions has something: '+str(r)) v.add_regions('r', r) r = v.get_regions('r') if r: print('see regions has something: '+str(r)) v.run_command('undo') r = v.get_regions('r') # this should work, but it doesn't if not r: print('bug!')
When the API does not work we have to resort to very ugly and not efficient hacks. See https://dl.dropboxusercontent.com/u/9303546/SublimeText/commands/undo_or_redo_without_moving_cursor_listener.py and https://forum.sublimetext.com/t/undo-and-redo-to-not-move-the-cursor/17988/4?u=tito
I'm running into similar problems. In general,
Example where this is weird:
In my use case, I am creating regions with unique keys, and I am tracking these keys in my plugin. When I erase all the regions (and stop tracking the keys), and the user presses undo, the regions return from the grave. Since my plugin is no longer tracking them, the user doesn't have an obvious way to dismiss the zombie regions.