Sublime Forum

[BUG] Using glueMarkedUndoGroups from a QuickPanel

#1

I’ve run into the following situation:
I’d like to use the “markUndoGroupsForGluing” and “glueMarkedUndoGroups” commands to support multiple-undo in my command.

This works fine in normal use, but when I try to use this as part of the “onDone” function which is run when a QuickPanel ends, the “glueMarkedUndoGroups” command runs out of memory.
I’m guessing this is either a problem with the way I’m using it, or a bug in the command itself as it relates to the QuickPanel.

Example code (this just adds “a” to the beginning of every selection in the view).
This crashes when run with selections on 20 lines (i.e. 20 selections at the beginning of each line).

class myTest(sublimeplugin.TextCommand):
   def run(self, view, args):
      self.view = view
      window = view.window()
      window.showInputPanel('Test', "", self.onDone, None, None)

   def onDone(self, input):
      selections = self.view.sel()
      to_insert = "a"] * len(selections)

      self.view.runCommand("markUndoGroupsForGluing")
      for i, region in enumerate(selections):
         self.view.replace(region, to_insert*)
      self.view.runCommand("glueMarkedUndoGroups")

Related thread: http://www.sublimetext.com/forum/viewtopic.php?f=6&t=1157&start=0*

0 Likes

#2

This is a bug in glueMarkedUndoGroups, it’ll be fixed in the next beta.

0 Likes

#3

Excellent, thanks!

0 Likes