Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update large file size limit #2162

Merged
merged 2 commits into from
Jan 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ export class TextmateService extends WithEventBus implements ITextmateTokenizerS
return;
}
const tokenizerOption: TokenizerOption = {
lineLimit: this.preferenceService.get('editor.maxTokenizationLineLength') || 10000,
lineLimit: this.preferenceService.get('editor.maxTokenizationLineLength') || 20000,
};
const configuration = this.textmateRegistry.getGrammarConfiguration(languageId)();
const initialLanguage = getEncodedLanguageId(languageId);
Expand Down
14 changes: 7 additions & 7 deletions packages/editor/src/browser/preference/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1601,7 +1601,7 @@ const monacoEditorSchema: PreferenceSchemaProperties = {
},
'editor.maxTokenizationLineLength': {
type: 'integer',
default: 20_000,
default: 20000,
description: localize(
'maxTokenizationLineLength',
'Lines above this length will not be tokenized for performance reasons',
Expand Down Expand Up @@ -1723,16 +1723,16 @@ const customEditorSchema: PreferenceSchemaProperties = {
default: false,
description: '%editor.configuration.forceReadOnly%',
},
// 会启用languageFeature的最大文件尺寸
// 会启用 languageFeature 的最大文件尺寸
'editor.languageFeatureEnabledMaxSize': {
type: 'number',
default: 2 * 1024 * 1024, // 2M
default: 4 * 1024 * 1024 * 1024, // 4096 MB
description: '%editor.configuration.languageFeatureEnabledMaxSize%',
},
// 会同步到extHost的最大文件尺寸, 必须大于等于 languageFeatureEnabledMaxSize
// 会同步到插件进程的最大文件尺寸, 必须大于等于 languageFeatureEnabledMaxSize
'editor.docExtHostSyncMaxSize': {
type: 'number',
default: 2 * 1024 * 1024, // 2M
default: 4 * 1024 * 1024 * 1024, // 4096 MB
description: '%editor.configuration.docExtHostSyncMaxSize%',
},
'editor.renderLineHighlight': {
Expand Down Expand Up @@ -1811,7 +1811,7 @@ const customEditorSchema: PreferenceSchemaProperties = {
},
'editor.maxTokenizationLineLength': {
type: 'integer',
default: 10000,
default: 20000,
description: '%editor.configuration.maxTokenizationLineLength%',
},
'editor.semanticHighlighting.enabled': {
Expand All @@ -1837,7 +1837,7 @@ const customEditorSchema: PreferenceSchemaProperties = {
},
'editor.largeFile': {
type: 'number',
default: 2 * 1024 * 1024,
default: 4 * 1024 * 1024 * 1024,
description: '%editor.configuration.largeFileSize%',
},
'editor.quickSuggestionsDelay': {
Expand Down
4 changes: 2 additions & 2 deletions packages/extension/src/browser/vscode/api/main.thread.doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ export class MainThreadExtensionDocumentData extends WithEventBus implements IMa
this.docSyncEnabled.set(
uriString,
docRef.instance.getMonacoModel().getValueLength() <
(this.preference.get<number>('editor.docExtHostSyncMaxSize') || 2 * 1024 * 1024),
(this.preference.get<number>('editor.docExtHostSyncMaxSize') || 4 * 1024 * 1024 * 1024),
);
docRef.dispose();
}
}
return this.docSyncEnabled.get(uriString)!;
return this.docSyncEnabled.get(uriString) ?? false;
}

constructor(@Optional(Symbol()) private rpcProtocol: IRPCProtocol) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class MainThreadLanguages implements IMainThreadLanguages {
this.languageFeatureEnabled.set(
uriString,
model.getValueLength() <
(this.preference.get<number>('editor.languageFeatureEnabledMaxSize') || 2 * 1024 * 1024),
(this.preference.get<number>('editor.languageFeatureEnabledMaxSize') || 4 * 1024 * 1024 * 1024),
);
}
return this.languageFeatureEnabled.get(uriString);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('contribution test', () => {
});

it('should fallback to LARGE_FILE_PREVENT_COMPONENT_ID if file is too large', async () => {
mockFileService.getFileStat.mockReturnValueOnce({ size: 114514 });
mockFileService.getFileStat.mockReturnValueOnce({ size: 4 * 1024 * 1024 * 1024 + 1 });
const openTypes = await registry.resolveEditorComponent(createMockResource('file:///foo/2.js'));
expect(openTypes[0].type).toBe('component');
expect(openTypes[0].componentId).toBe('large-file-prevent');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class FileSystemEditorComponentContribution implements BrowserEditorContr
if (type === 'text') {
const { metadata, uri } = resource as { uri: URI; metadata: any };
const stat = await this.fileServiceClient.getFileStat(uri.toString());
const maxSize = this.preference.get<number>('editor.largeFile') || 20000;
const maxSize = this.preference.get<number>('editor.largeFile') || 4 * 1024 * 1024 * 1024;

if (stat && (stat.size || 0) > maxSize && !(metadata || {}).noPrevent) {
results.push({
Expand Down