Skip to content

Commit 5db76fd

Browse files
author
Jackson Kearl
authored
Jackson/lang-detect-min-text (microsoft#144105)
* Add first pass at reducing non-confident guesses * Swap ordering of conditions
1 parent 1943737 commit 5db76fd

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/vs/workbench/services/languageDetection/browser/languageDetectionSimpleWorker.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,13 @@ export class LanguageDetectionSimpleWorker extends EditorSimpleWorker {
5656
};
5757

5858
const historicalResolver = async () => {
59+
// only detect when we have at least a line of data
5960
if (langBiases) {
60-
const regexpDetection = await this.runRegexpModel(documentTextSample, langBiases);
61-
if (regexpDetection) {
62-
return regexpDetection;
61+
if (documentTextSample.length > 20 || documentTextSample.includes('\n')) {
62+
const regexpDetection = await this.runRegexpModel(documentTextSample, langBiases);
63+
if (regexpDetection) {
64+
return regexpDetection;
65+
}
6366
}
6467
}
6568
return undefined;

0 commit comments

Comments
 (0)