void () { myProject.getMessageBus().connect().subscribe( FileEditorManagerListener.Before.FILE_EDITOR_MANAGER, new FileEditorManagerListener.Before() { @Override public void beforeFileClosed(@NotNull FileEditorManager source, @NotNull VirtualFile file) { putInGrave(source, file); } } ); }