avoid calling getFileType on before content change unless absolutely necessary (IDEA-133507)

This commit is contained in:
Maxim.Mossienko
2014-12-04 13:30:52 +01:00
parent 1bd826094e
commit addaa53499
@@ -748,7 +748,8 @@ public class FileDocumentManagerImpl extends FileDocumentManager implements Virt
@Override
public void beforeContentsChange(@NotNull VirtualFileEvent event) {
VirtualFile virtualFile = event.getFile();
if (virtualFile.getFileType() == UnknownFileType.INSTANCE && virtualFile.getLength() == 0) {
// check file type in second order to avoid content detection running
if (virtualFile.getLength() == 0 && virtualFile.getFileType() == UnknownFileType.INSTANCE) {
virtualFile.putUserData(MUST_RECOMPUTE_FILE_TYPE, Boolean.TRUE);
}
}