Manipulating a Document without undo-history
I'm showing a Document in a EditorTextField on a dialog.
In the initialization code, I'm performing some string manipulations on the
Document (using RangeMarkers makes this easy).
IDEA insists that I perform any mutations on the Document inside a runWriteAction()+executeCommand().
Questions
1) Is it possible to use a Document in a "background" (non-UI) fashion, without
all the runWriteAction()+executeCommand() nesting? I'd like to use RangeMarkers
etc, but without any UI.
2) If I perform the mutations inside runWriteAction()+executeCommand(), they're
pushed on the undo stack. How do I get the editor that's showing my Document
to start with an empty undo stack?
Thanks,
Taras
Please sign in to leave a comment.
Hello Taras,
Don't know. Probably not. Though there's nothing that stops you from using a Document
without any UI - except that you have to modify it from the EDT + WriteAction + Command.
You might find com.intellij.openapi.command.undo.UndoManager#clearUndoRedoQueue useful for
that. I haven't tried it though.
Sascha
>> 2) If I perform the mutations inside
>> runWriteAction()+executeCommand(), they're pushed on the undo stack.
>> How do I get the editor that's showing my Document to start with an
>> empty undo stack?
PS: com.intellij.openapi.command.CommandProcessor#runUndoTransparentAction might work for
you as well - at least the name suggests that it could, but there's an (unanswered post)
that says it doesn't work for Documents:
http://www.intellij.net/forums/click.jspa?searchID=306048&messageID=5109652
Sascha
Hello Sascha,
Ah yes, I keep finding that old (unanswered) post whenever I search for anything
CommandProcessor related. :)
By the way, the results are:
-CommandProcessor#runUndoTransparentAction: does not work for me
-UndoManager#clearUndoRedoQueue: works perfectly!
Thanks,
Taras