int (@NotNull VirtualFile file) { if (!file.isCharsetSet()) { // when detecting type from content of a file with unknown charset we have to determine charset first, // which in turn may require file content. But in this case, the whole file content because the UTF surrogates may very well be at the end of the file. return FileUtilRt.getUserContentLoadLimit(); } int bufferLength = cachedDetectFileBufferSize; if (bufferLength == -1) { List<FileTypeRegistry.FileTypeDetector> detectors = FileTypeRegistry.FileTypeDetector.EP_NAME.getExtensionList(); //noinspection ForLoopReplaceableByForEach for (int i = 0; i < detectors.size(); i++) { FileTypeRegistry.FileTypeDetector detector = detectors.get(i); bufferLength = Math.max(bufferLength, detector.getDesiredContentPrefixLength()); } if (bufferLength < 0) { bufferLength = FileUtilRt.getUserContentLoadLimit(); } cachedDetectFileBufferSize = bufferLength; } return bufferLength; }