Undo eventually erases all code

Questions on using RSyntaxTextArea should go here.

Moderator: robert

Undo eventually erases all code

Postby omadawn » Tue Aug 07, 2012 10:05 pm

The built in undo/redo functionality of RSTA is yet another fantastic feature but it does cause one bug in my code. If I hit it enough times it blanks out all the code I have in the editor window. Presumably it is 'undoing' the initial loading of the script I am doing with myTextarea.setText().

Is there a way to tell it to start from a certain point that I can trigger after I load the text?
omadawn
 
Posts: 38
Joined: Sat Jul 21, 2012 7:39 pm

Re: Undo eventually erases all code

Postby robert » Fri Aug 10, 2012 12:42 pm

After initializing the editor, all textArea.discardAllEdits().
User avatar
robert
 
Posts: 774
Joined: Sat May 10, 2008 5:16 pm

Re: Undo eventually erases all code

Postby omadawn » Sat Aug 18, 2012 12:05 am

Thank you. That solves that issue. I guess I just assumed that the undo behavior indicated that setText was considered an edit and undoAllAdits() was going to clear that out. I should have tested it.
omadawn
 
Posts: 38
Joined: Sat Jul 21, 2012 7:39 pm

Re: Undo eventually erases all code

Postby robert » Sat Aug 18, 2012 2:39 pm

If you use a TextEditorPane (extends RSyntaxTextArea but adds loading, saving, dirty checking, etc.), it will automatically clear the undo stack when loading a new file into the editor.
User avatar
robert
 
Posts: 774
Joined: Sat May 10, 2008 5:16 pm

Re: Undo eventually erases all code

Postby omadawn » Sun Aug 19, 2012 8:44 pm

I am using TextEditorPane but it isn't automatically clearing the undo history. The above mechanism is working though.
omadawn
 
Posts: 38
Joined: Sat Jul 21, 2012 7:39 pm

Re: Undo eventually erases all code

Postby robert » Tue Aug 21, 2012 4:14 am

Sorry, I should have been more clear. If you use one of TextEditorPane's load(), save(), or saveAs() methods, it should automatically clear the undo stack. If it doesn't then it's a bug. Calling setText() will always be an undoable edit, as you've noticed.

You might need the latest from SVN for this though, as I noticed at least one instance recently where this wasn't happening.
User avatar
robert
 
Posts: 774
Joined: Sat May 10, 2008 5:16 pm

Re: Undo eventually erases all code

Postby omadawn » Wed Aug 22, 2012 2:26 am

Now that makes more sense. I'm actually instantiating the texteditorpane with the fileLocation as an argument which is equivalent to Load() and that DOES work. ^_^
omadawn
 
Posts: 38
Joined: Sat Jul 21, 2012 7:39 pm


Return to Help

Who is online

Users browsing this forum: No registered users and 3 guests

cron