提交 7b095337 编写于 作者: P Peng Lyu

Relaunch the application to accept jsflags.

上级 056d6221
......@@ -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
......
......@@ -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 ((<FileOperationError>error).fileOperationResult === FileOperationResult.FILE_EXCEED_MEMORY_LIMIT) {
let memoryLimit = this.configurationService.getValue<number>(null, 'files.maxMemoryForLargeFilesMB');
let memoryLimit = this.configurationService.getValue<number>(null, 'files.maxMemoryForLargeFilesMB') | 4096;
return TPromise.wrapError<void>(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 => {
......
......@@ -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.")
}
}
});
......
......@@ -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<number>(null, 'files.maxMemoryForLargeFilesMB');
let memoryLimit = this.textResourceConfigurationService.getValue<number>(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<number>(null, 'files.maxMemoryForLargeFilesMB');
let memoryLimit = this.textResourceConfigurationService.getValue<number>(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
));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册