未验证 提交 78c0836f 编写于 作者: P Peng Lyu 提交者: GitHub

Merge pull request #68665 from jeanp413/fix-68279

Fix --max-memory argument incorrect parsing
......@@ -62,7 +62,7 @@ export interface ParsedArgs {
'disable-updates'?: string;
'disable-crash-reporter'?: string;
'skip-add-to-recently-opened'?: boolean;
'max-memory'?: number;
'max-memory'?: string;
'file-write'?: boolean;
'file-chmod'?: boolean;
'upload-logs'?: string;
......
......@@ -61,7 +61,7 @@ export const options: Option[] = [
{ id: 'inspect-brk-extensions', type: 'string', deprecates: 'debugBrkPluginHost', args: 'port', cat: 't', description: localize('inspect-brk-extensions', "Allow debugging and profiling of extensions with the extension host being paused after start. Check the developer tools for the connection URI.") },
{ id: 'disable-gpu', type: 'boolean', cat: 't', description: localize('disableGPU', "Disable GPU hardware acceleration.") },
{ id: 'upload-logs', type: 'string', cat: 't', description: localize('uploadLogs', "Uploads logs from current session to a secure endpoint.") },
{ id: 'max-memory', type: 'boolean', cat: 't', description: localize('maxMemory', "Max memory size for a window (in Mbytes).") },
{ id: 'max-memory', type: 'string', cat: 't', description: localize('maxMemory', "Max memory size for a window (in Mbytes).") },
{ id: 'remote', type: 'string' },
{ id: 'extensionDevelopmentPath', type: 'string' },
......
......@@ -17,7 +17,8 @@ function validate(args: ParsedArgs): ParsedArgs {
}
if (args['max-memory']) {
assert(args['max-memory'] >= MIN_MAX_MEMORY_SIZE_MB, `The max-memory argument cannot be specified lower than ${MIN_MAX_MEMORY_SIZE_MB} MB.`);
console.log(parseInt(args['max-memory']));
assert(parseInt(args['max-memory']) >= MIN_MAX_MEMORY_SIZE_MB, `The max-memory argument cannot be specified lower than ${MIN_MAX_MEMORY_SIZE_MB} MB.`);
}
return args;
......
......@@ -311,7 +311,7 @@ export class FileService extends Disposable implements IFileService {
// Return early if file is too large to load
if (typeof stat.size === 'number') {
if (stat.size > Math.max(this.environmentService.args['max-memory'] * 1024 * 1024 || 0, MAX_HEAP_SIZE)) {
if (stat.size > Math.max(parseInt(this.environmentService.args['max-memory']) * 1024 * 1024 || 0, MAX_HEAP_SIZE)) {
return onStatError(new FileOperationError(
nls.localize('fileTooLargeForHeapError', "To open a file of this size, you need to restart VS Code and allow it to use more memory"),
FileOperationResult.FILE_EXCEED_MEMORY_LIMIT
......@@ -485,7 +485,7 @@ export class FileService extends Disposable implements IFileService {
currentPosition += bytesRead;
}
if (totalBytesRead > Math.max(this.environmentService.args['max-memory'] * 1024 * 1024 || 0, MAX_HEAP_SIZE)) {
if (totalBytesRead > Math.max(parseInt(this.environmentService.args['max-memory']) * 1024 * 1024 || 0, MAX_HEAP_SIZE)) {
finish(new FileOperationError(
nls.localize('fileTooLargeForHeapError', "To open a file of this size, you need to restart VS Code and allow it to use more memory"),
FileOperationResult.FILE_EXCEED_MEMORY_LIMIT
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册