Intellij IDEA 无法撤消

发布于 2024-12-15 07:14:52 字数 276 浏览 2 评论 0原文

我正在 Intellij IDEA 从事一个项目。我搬家重构了一些包。但是我想撤消我的更改。当我点击恢复按钮时,它显示

无法撤消

,并在其下显示一个列表:

受此操作影响的以下文件已被更改

由于丢失了一些文件,我如何恢复我的更改包和类。 Intellij IDEA 是否将它们保存在临时文件夹中?

PS:我在64位Ubuntu计算机上使用open jdk 1.6.0。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

许久 2024-12-22 07:14:52

IntelliJ IDEA 有一个很棒的功能,称为本地历史记录。我可以恢复我的更改。 有一个视频给出了详细的示例:

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

您可以从这里获取更多信息:http://jetbrains.com/help/idea/2016.1/using-local-history .html

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

甜`诱少女 2024-12-22 07:14:52

通过 VCS 撤消它 -->当地历史 -->显示历史。

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

爱她像谁 2024-12-22 07:14:52

当我开发 IntelliJ 插件 emacsIDEAs 时,我多次用谷歌搜索到这里,我会将我的解决方案留在这里,供有需要的人使用。

通常对文档的更改需要在runWriteAction中完成,
要撤消对文档的更改,需要在 CommandProcessor.getInstance().executeCommand 中调用,

因此解决方案是:在 runWriteAction 中调用 executeCommand,然后更改将是不可撤销的。

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));

代码仓库: https://github.com/whunmr/emacsIDEAs

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文