I’m trying to automatically execute some logic that modifies the editor’s content when the IDE is closed.
override fun dispose() {
WriteCommandAction.runWriteCommandAction(project) {
log.info("Editor old state:\n```\n${editor.document.text}\n```")
editor.document.deleteString(startOffset, endOffset)
log.info("Editor new state:\n```\n${editor.document.text}\n```")
}
}
Example
- runIde is closing.
- editor old state:
a
b
c
- delete b
- editor new state:
a
c
but in another’s IDE
a
b
c
I’ve added some logging for debugging purposes. When I close the generated IDE (runIde
), the main IDE can still hit breakpoints, and I can see the logs showing the expected updates — specifically, the new state reflect the deleted code.
However, when I open the same file in another editor to verify, the changes don’t seem to be applied — the line isn’t actually deleted.
Does anyone have suggestions on how to properly update the editor document during IDE shutdown?