From 7b0953377989c0b588f48e72178f5132eec3ad16 Mon Sep 17 00:00:00 2001 From: Peng Lyu Date: Thu, 22 Mar 2018 17:31:56 -0700 Subject: [PATCH] Relaunch the application to accept jsflags. --- src/vs/code/electron-main/window.ts | 1 - .../parts/files/browser/editors/textFileEditor.ts | 14 +++++++++----- .../files/electron-browser/files.contribution.ts | 2 +- .../workbench/services/files/node/fileService.ts | 8 ++++---- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/vs/code/electron-main/window.ts b/src/vs/code/electron-main/window.ts index fbf636563ca..dbd4821bea1 100644 --- a/src/vs/code/electron-main/window.ts +++ b/src/vs/code/electron-main/window.ts @@ -560,7 +560,6 @@ export class CodeWindow implements ICodeWindow { if (cli) { configuration['disable-extensions'] = cli['disable-extensions']; - configuration['max-memory'] = cli['max-memory']; } configuration.isInitialStartup = false; // since this is a reload diff --git a/src/vs/workbench/parts/files/browser/editors/textFileEditor.ts b/src/vs/workbench/parts/files/browser/editors/textFileEditor.ts index c13d712d539..05f2bfad02c 100644 --- a/src/vs/workbench/parts/files/browser/editors/textFileEditor.ts +++ b/src/vs/workbench/parts/files/browser/editors/textFileEditor.ts @@ -30,7 +30,7 @@ import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/edi import { IThemeService } from 'vs/platform/theme/common/themeService'; import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService'; import { ScrollType } from 'vs/editor/common/editorCommon'; -import { IWindowService } from 'vs/platform/windows/common/windows'; +import { IWindowsService } from 'vs/platform/windows/common/windows'; /** * An implementation of editor for file system resources. @@ -51,7 +51,7 @@ export class TextFileEditor extends BaseTextEditor { @IThemeService themeService: IThemeService, @IEditorGroupService editorGroupService: IEditorGroupService, @ITextFileService textFileService: ITextFileService, - @IWindowService private windowService: IWindowService, + @IWindowsService private windowsService: IWindowsService, @IPreferencesService private preferencesService: IPreferencesService ) { super(TextFileEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, textFileService, editorGroupService); @@ -171,12 +171,16 @@ export class TextFileEditor extends BaseTextEditor { } if ((error).fileOperationResult === FileOperationResult.FILE_EXCEED_MEMORY_LIMIT) { - let memoryLimit = this.configurationService.getValue(null, 'files.maxMemoryForLargeFilesMB'); + let memoryLimit = this.configurationService.getValue(null, 'files.maxMemoryForLargeFilesMB') | 4096; return TPromise.wrapError(errors.create(toErrorMessage(error), { actions: [ - new Action('workbench.window.action.reloadWithIncreasedMemoryLimit', nls.localize('reloadWithIncreasedMemoryLimit', "Reload"), null, true, () => { - return this.windowService.reloadWindow({ _: [], 'max-memory': memoryLimit }).then(() => true); + new Action('workbench.window.action.relaunchWithIncreasedMemoryLimit', nls.localize('relaunchWithIncreasedMemoryLimit', "Relaunch"), null, true, () => { + return this.windowsService.relaunch({ + addArgs: [ + `--max-memory=${memoryLimit}` + ] + }); }), new Action('workbench.window.action.configureMemoryLimit', nls.localize('configureMemoryLimit', 'Configure'), null, true, () => { return this.preferencesService.openGlobalSettings().then(editor => { diff --git a/src/vs/workbench/parts/files/electron-browser/files.contribution.ts b/src/vs/workbench/parts/files/electron-browser/files.contribution.ts index d6bf31f0576..69e208012e1 100644 --- a/src/vs/workbench/parts/files/electron-browser/files.contribution.ts +++ b/src/vs/workbench/parts/files/electron-browser/files.contribution.ts @@ -286,7 +286,7 @@ configurationRegistry.registerConfiguration({ 'files.maxMemoryForLargeFilesMB': { 'type': 'number', 'default': 4096, - 'description': nls.localize('maxMemoryForLargeFilesMB', "The new limit on memory in MB to be used by the application when reloading to open large files. If you wish to start with a higher limit, you can launch the application from command line with --max-memory=NEWSIZE.") + 'description': nls.localize('maxMemoryForLargeFilesMB', "The new limit on memory in MB to be used by the application when relaunching to open large files. If you wish to start with a higher limit, you can launch the application from command line with --max-memory=NEWSIZE.") } } }); diff --git a/src/vs/workbench/services/files/node/fileService.ts b/src/vs/workbench/services/files/node/fileService.ts index 680c6f25fd9..873c0914b1e 100644 --- a/src/vs/workbench/services/files/node/fileService.ts +++ b/src/vs/workbench/services/files/node/fileService.ts @@ -318,9 +318,9 @@ export class FileService 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)) { - let memoryLimit = this.textResourceConfigurationService.getValue(null, 'files.maxMemoryForLargeFilesMB'); + let memoryLimit = this.textResourceConfigurationService.getValue(null, 'files.maxMemoryForLargeFilesMB') | 4096; return onStatError(new FileOperationError( - nls.localize('fileTooLargeForHeapError', "File size exceeds the default memory limit. Reload the window with a higher limit. The current setting is configured to reload with {0}MB", memoryLimit), + nls.localize('fileTooLargeForHeapError', "File size exceeds the default memory limit. Relaunch with a higher limit. The current setting is configured to relaunch with {0}MB", memoryLimit), FileOperationResult.FILE_EXCEED_MEMORY_LIMIT )); } @@ -469,9 +469,9 @@ export class FileService implements IFileService { } if (totalBytesRead > Math.max(this.environmentService.args['max-memory'] * 1024 * 1024 || 0, MAX_HEAP_SIZE)) { - let memoryLimit = this.textResourceConfigurationService.getValue(null, 'files.maxMemoryForLargeFilesMB'); + let memoryLimit = this.textResourceConfigurationService.getValue(null, 'files.maxMemoryForLargeFilesMB') | 4096; finish(new FileOperationError( - nls.localize('fileTooLargeForHeapError', "File size exceeds the default memory limit. Reload the window with a higher limit. The current setting is configured to reload with {0}MB", memoryLimit), + nls.localize('fileTooLargeForHeapError', "File size exceeds the default memory limit. Relaunch with a higher limit. The current setting is configured to relaunch with {0}MB", memoryLimit), FileOperationResult.FILE_EXCEED_MEMORY_LIMIT )); } -- GitLab