Intellij IDEA Cannot Undo
Asked Answered
M

3

20

I am working on a project at Intellij IDEA. I moved refactored some packages. However I want to undo my changes. When I click revert button it says

Cannot Undo

and shows a list under that:

Following files affected by this action have been already changed

How can I revert my changes because I lost some packages and classes. Does Intellij IDEA keeps them inside a temporary folder?

PS: I use open jdk 1.6.0 on a 64 bit Ubuntu computer.

Monomer answered 12/11, 2011 at 17:20 Comment(0)
M
28

IntelliJ IDEA has a great feature called as local history. I could revert my changes. There is a video gives a detailed example for it:

http://www.jetbrains.com/idea/training/demos/local_history.html

You can get more information from here: http://jetbrains.com/help/idea/2016.1/using-local-history.html

Monomer answered 12/11, 2011 at 17:38 Comment(6)
Thanks to Serge Baranov from Intellij IDEA support team. He answered my question immediately when I asked from support page.Monomer
Yes, IntelliJ support guys are awesome that's one of the reasons (not the only one) for which I prefer IntelliJ over EclipseTannin
But in case I want revert change then i really want to revert the change. but it still shows in i checking from the directory. Keeping local history is one thing but keeping the history for the SVN is another. I expect the intellij not to show anything in the SVN commit or revert once the file has been reverted.Dartmoor
annnnnd link's deadCalculate
@Calculate here is an explanation instead of dead link: jetbrains.com/help/idea/2016.1/using-local-history.htmlMonomer
Answers that are links aren't generally accepted as answers because links can die. Please flesh out your answer with the contents from the link.Mantis
S
16

Undo it through VCS --> Local History --> Show History.

Shandrashandrydan answered 23/3, 2015 at 15:2 Comment(0)
T
3

As I googled to here several times when I developing IntelliJ plugin emacsIDEAs, I will leave my solution here for someone who need it.

usually change to document need be done in runWriteAction, and for undo changes to document need called in CommandProcessor.getInstance().executeCommand

so the solution is: call executeCommand in runWriteAction, then the changes will be undoable.

protected Runnable getRunnableWrapper(final Runnable runnable) {
    return new Runnable() {
        @Override
        public void run() {
            CommandProcessor.getInstance().executeCommand(_editor.getProject(), runnable, "cut", ActionGroup.EMPTY_GROUP);
        }
    };
}

final Runnable runnable = new Runnable() {
    @Override
    public void run() {
        selectJumpArea(jumpTargetOffset);
        _editor.getSelectionModel().copySelectionToClipboard();
        EditorModificationUtil.deleteSelectedText(_editor);
        _editor.getSelectionModel().removeSelection();
    }
};

ApplicationManager.getApplication().runWriteAction(getRunnableWrapper(runnable));

code repo: https://github.com/whunmr/emacsIDEAs

Tent answered 23/1, 2013 at 4:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.