Intellij IDEA Cannot Undo

匿名 (未验证) 提交于 2019-12-03 00:46:02

问题:

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.

回答1:

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



回答2:

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



回答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



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!