mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
Don't pass entire file content to file type detectors (avoid performance issues such as https://youtrack.jetbrains.com/issue/IDEA-286489)
GitOrigin-RevId: 73f666ed8e678c818dacfc62518ed911e7afe0dc
This commit is contained in:
committed by
intellij-monorepo-bot
parent
7a559d8394
commit
029964c1b6
@@ -608,8 +608,8 @@ final class FileTypeDetectionService implements Disposable {
|
||||
|
||||
@NotNull
|
||||
private ByteArraySequence getFirstBytes(@NotNull VirtualFile file, byte @Nullable [] content) throws IOException {
|
||||
int bufferLength = getDetectFileBufferSize(file);
|
||||
if (content == null) {
|
||||
int bufferLength = getDetectFileBufferSize(file);
|
||||
try {
|
||||
return ProgressManager.getInstance().isInNonCancelableSection() || ApplicationManager.getApplication().isWriteThread()
|
||||
? readFirstBytesFromFile(file, bufferLength)
|
||||
@@ -620,7 +620,7 @@ final class FileTypeDetectionService implements Disposable {
|
||||
}
|
||||
}
|
||||
else {
|
||||
return content.length != 0 ? new ByteArraySequence(content) : ByteArraySequence.EMPTY;
|
||||
return content.length != 0 ? new ByteArraySequence(content, 0, Math.min(content.length, bufferLength)) : ByteArraySequence.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user