LightEditorInfo (@NotNull LightEditorInfo info, @NotNull VirtualFile targetFile) { LightEditorInfo newInfo = createEditor(targetFile); if (newInfo != null) { ApplicationManager.getApplication().runWriteAction(() -> { FileDocumentManager manager = FileDocumentManager.getInstance(); Document source = manager.getDocument(info.getFile()); Document target = manager.getDocument(targetFile); if (source == null) { LOG.error("Cannot save to " + targetFile + ": no document found for " + info.getFile()); return; } if (target == null) { LOG.error("Cannot save to " + targetFile + ": no document found for " + targetFile); return; } targetFile.refresh(false, false); // to avoid memory-disk conflict if target file was changed externally target.setText(source.getCharsSequence()); manager.saveDocument(target); }); return newInfo; } return info; }