修复新增文件时产生索引异常问题

This commit is contained in:
makejava 2020-06-15 23:07:20 +08:00
parent 1ec88794ec
commit 46483427d9
1 changed files with 2 additions and 0 deletions

View File

@ -150,6 +150,8 @@ public class FileUtils {
PsiDirectory finalPsiDirectory = psiDirectory;
PsiFile finalFile = WriteCommandAction.runWriteCommandAction(saveFile.getProject(), (Computable<PsiFile>) () -> {
if (oldFile == null) {
// 提交所有改动并非VCS中的提交文件
PsiDocumentManager.getInstance(saveFile.getProject()).commitAllDocuments();
return (PsiFile) finalPsiDirectory.add(saveFile.getFile());
} else {
// 对旧文件进行替换操作