我正在为 IntelliJ Idea 13 开发一个插件。我做了一些更改beforeDocumentSaving
并使用document.setText
:
public class AppendAction implements ApplicationComponent
{
@Override public void initComponent()
{
MessageBus bus = ApplicationManager.getApplication().getMessageBus();
MessageBusConnection connection = bus.connect();
connection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerAdapter()
{
@Override public void beforeDocumentSaving(Document document)
{
document.setText(appendSomething(document.getText()));
}
});
}
}
这很好用,我唯一的问题是,当这个插件运行时,我想撤消更改,我得到以下错误消息:
Cannot Undo
Following files have changes that cannot be undone:
有吗Idea
?:-)