未验证 提交 50c09aac 编写于 作者: S SteVen Batten 提交者: GitHub

Add button to reload window with increase memory limit (#46220)

* adding dialog to reload window with increased memory limit (configurable via new setting)
上级 03eff8e8
......@@ -560,6 +560,7 @@ 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
......
......@@ -28,6 +28,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';
/**
* An implementation of editor for file system resources.
......@@ -48,6 +49,7 @@ export class TextFileEditor extends BaseTextEditor {
@IThemeService themeService: IThemeService,
@IEditorGroupService editorGroupService: IEditorGroupService,
@ITextFileService textFileService: ITextFileService,
@IWindowService private windowService: IWindowService
) {
super(TextFileEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, textFileService, editorGroupService);
......@@ -165,6 +167,18 @@ export class TextFileEditor extends BaseTextEditor {
}));
}
if ((<FileOperationError>error).fileOperationResult === FileOperationResult.FILE_EXCEED_MEMORY_LIMIT) {
let memoryLimit = this.configurationService.getValue<number>(null, 'files.maxMemoryForLargeFilesMB');
return TPromise.wrapError<void>(errors.create(toErrorMessage(error), {
actions: [
new Action('workbench.window.action.reloadWithIncreasedMemoryLimit', nls.localize('reloadWithIncreasedMemoryLimit', "Reload with {0}MB", memoryLimit), null, true, () => {
return this.windowService.reloadWindow({ _: [], 'max-memory': memoryLimit }).then(() => true);
})
]
}));
}
// Otherwise make sure the error bubbles up
return TPromise.wrapError<void>(error);
});
......
......@@ -282,6 +282,11 @@ configurationRegistry.registerConfiguration({
'files.defaultLanguage': {
'type': 'string',
'description': nls.localize('defaultLanguage', "The default language mode that is assigned to new files.")
},
'files.maxMemoryForLargeFilesMB': {
'type': 'number',
'default': 4096,
'description': nls.localize('maxMemoryForLargeFilesMB', "The new limit on memory in MB to be used by the application when trying to open large files. Alternatively, you can launch the application with --max-memory=NEWSIZE.")
}
}
});
......
......@@ -319,7 +319,7 @@ export class FileService implements IFileService {
if (typeof stat.size === 'number') {
if (stat.size > Math.max(this.environmentService.args['max-memory'] * 1024 * 1024 || 0, MAX_HEAP_SIZE)) {
return onStatError(new FileOperationError(
nls.localize('fileTooLargeForHeapError', "File size exceeds window memory limit, please try to run code --max-memory=NEWSIZE"),
nls.localize('fileTooLargeForHeapError', "File size exceeds window memory limit. Try launching with a higher memory limit"),
FileOperationResult.FILE_EXCEED_MEMORY_LIMIT
));
}
......@@ -469,7 +469,7 @@ export class FileService implements IFileService {
if (totalBytesRead > Math.max(this.environmentService.args['max-memory'] * 1024 * 1024 || 0, MAX_HEAP_SIZE)) {
finish(new FileOperationError(
nls.localize('fileTooLargeForHeapError', "File size exceeds window memory limit, please try to run code --max-memory=NEWSIZE"),
nls.localize('fileTooLargeForHeapError', "File size exceeds window memory limit. Try launching with a higher memory limit"),
FileOperationResult.FILE_EXCEED_MEMORY_LIMIT
));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册