Merge pull request #44988 from mechatroner/master

move huge file params to user config for Microsoft/vscode#44986 and mechatroner/vscode_rainbow_csv#3
This commit is contained in:
Alexandru Dima 2018-04-09 10:23:59 +02:00 committed by GitHub
commit fbe4d3700b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 44 additions and 6 deletions

View file

@ -668,6 +668,16 @@ const editorConfiguration: IConfigurationNode = {
'default': true, 'default': true,
'description': nls.localize('ignoreTrimWhitespace', "Controls if the diff editor shows changes in leading or trailing whitespace as diffs") 'description': nls.localize('ignoreTrimWhitespace', "Controls if the diff editor shows changes in leading or trailing whitespace as diffs")
}, },
'editor.largeFileSize': {
'type': 'number',
'default': EDITOR_MODEL_DEFAULTS.largeFileSize,
'description': nls.localize('largeFileSize', "Controls file size threshold in bytes beyond which special optimization rules are applied")
},
'editor.largeFileLineCount': {
'type': 'number',
'default': EDITOR_MODEL_DEFAULTS.largeFileLineCount,
'description': nls.localize('largeFileLineCount', "Controls file size threshold in terms of line count beyond which special optimization rules are applied")
},
'diffEditor.renderIndicators': { 'diffEditor.renderIndicators': {
'type': 'boolean', 'type': 'boolean',
'default': true, 'default': true,

View file

@ -2204,7 +2204,9 @@ export const EDITOR_MODEL_DEFAULTS = {
tabSize: 4, tabSize: 4,
insertSpaces: true, insertSpaces: true,
detectIndentation: true, detectIndentation: true,
trimAutoWhitespace: true trimAutoWhitespace: true,
largeFileSize: 20 * 1024 * 1024, // 20 MB
largeFileLineCount: 300 * 1000 // 300K lines
}; };
/** /**

View file

@ -396,6 +396,8 @@ export interface ITextModelCreationOptions {
trimAutoWhitespace: boolean; trimAutoWhitespace: boolean;
defaultEOL: DefaultEndOfLine; defaultEOL: DefaultEndOfLine;
isForSimpleWidget: boolean; isForSimpleWidget: boolean;
largeFileSize: number;
largeFileLineCount: number;
} }
export interface ITextModelUpdateOptions { export interface ITextModelUpdateOptions {

View file

@ -155,8 +155,6 @@ class TextModelSnapshot implements ITextSnapshot {
export class TextModel extends Disposable implements model.ITextModel { export class TextModel extends Disposable implements model.ITextModel {
private static readonly MODEL_SYNC_LIMIT = 50 * 1024 * 1024; // 50 MB private static readonly MODEL_SYNC_LIMIT = 50 * 1024 * 1024; // 50 MB
private static readonly MODEL_TOKENIZATION_LIMIT = 20 * 1024 * 1024; // 20 MB
private static readonly MANY_MANY_LINES = 300 * 1000; // 300K lines
public static DEFAULT_CREATION_OPTIONS: model.ITextModelCreationOptions = { public static DEFAULT_CREATION_OPTIONS: model.ITextModelCreationOptions = {
isForSimpleWidget: false, isForSimpleWidget: false,
@ -165,6 +163,8 @@ export class TextModel extends Disposable implements model.ITextModel {
detectIndentation: false, detectIndentation: false,
defaultEOL: model.DefaultEndOfLine.LF, defaultEOL: model.DefaultEndOfLine.LF,
trimAutoWhitespace: EDITOR_MODEL_DEFAULTS.trimAutoWhitespace, trimAutoWhitespace: EDITOR_MODEL_DEFAULTS.trimAutoWhitespace,
largeFileSize: EDITOR_MODEL_DEFAULTS.largeFileSize,
largeFileLineCount: EDITOR_MODEL_DEFAULTS.largeFileLineCount,
}; };
public static createFromString(text: string, options: model.ITextModelCreationOptions = TextModel.DEFAULT_CREATION_OPTIONS, languageIdentifier: LanguageIdentifier = null, uri: URI = null): TextModel { public static createFromString(text: string, options: model.ITextModelCreationOptions = TextModel.DEFAULT_CREATION_OPTIONS, languageIdentifier: LanguageIdentifier = null, uri: URI = null): TextModel {
@ -289,8 +289,8 @@ export class TextModel extends Disposable implements model.ITextModel {
// If a model is too large at construction time, it will never get tokenized, // If a model is too large at construction time, it will never get tokenized,
// under no circumstances. // under no circumstances.
this._isTooLargeForTokenization = ( this._isTooLargeForTokenization = (
(bufferTextLength > TextModel.MODEL_TOKENIZATION_LIMIT) (bufferTextLength > creationOptions.largeFileSize)
|| (bufferLineCount > TextModel.MANY_MANY_LINES) || (bufferLineCount > creationOptions.largeFileLineCount)
); );
this._shouldSimplifyMode = ( this._shouldSimplifyMode = (

View file

@ -197,6 +197,8 @@ interface IRawConfig {
insertSpaces?: any; insertSpaces?: any;
detectIndentation?: any; detectIndentation?: any;
trimAutoWhitespace?: any; trimAutoWhitespace?: any;
largeFileSize?: any;
largeFileLineCount?: any;
}; };
} }
@ -275,13 +277,31 @@ export class ModelServiceImpl implements IModelService {
detectIndentation = (config.editor.detectIndentation === 'false' ? false : Boolean(config.editor.detectIndentation)); detectIndentation = (config.editor.detectIndentation === 'false' ? false : Boolean(config.editor.detectIndentation));
} }
let largeFileSize = EDITOR_MODEL_DEFAULTS.largeFileSize;
if (config.editor && typeof config.editor.largeFileSize !== 'undefined') {
let parsedlargeFileSize = parseInt(config.editor.largeFileSize, 10);
if (!isNaN(parsedlargeFileSize)) {
largeFileSize = parsedlargeFileSize;
}
}
let largeFileLineCount = EDITOR_MODEL_DEFAULTS.largeFileLineCount;
if (config.editor && typeof config.editor.largeFileLineCount !== 'undefined') {
let parsedlargeFileLineCount = parseInt(config.editor.largeFileLineCount, 10);
if (!isNaN(parsedlargeFileLineCount)) {
largeFileLineCount = parsedlargeFileLineCount;
}
}
return { return {
isForSimpleWidget: isForSimpleWidget, isForSimpleWidget: isForSimpleWidget,
tabSize: tabSize, tabSize: tabSize,
insertSpaces: insertSpaces, insertSpaces: insertSpaces,
detectIndentation: detectIndentation, detectIndentation: detectIndentation,
defaultEOL: newDefaultEOL, defaultEOL: newDefaultEOL,
trimAutoWhitespace: trimAutoWhitespace trimAutoWhitespace: trimAutoWhitespace,
largeFileSize: largeFileSize,
largeFileLineCount: largeFileLineCount
}; };
} }

View file

@ -22,6 +22,8 @@ export interface IRelaxedTextModelCreationOptions {
trimAutoWhitespace?: boolean; trimAutoWhitespace?: boolean;
defaultEOL?: DefaultEndOfLine; defaultEOL?: DefaultEndOfLine;
isForSimpleWidget?: boolean; isForSimpleWidget?: boolean;
largeFileSize?: number;
largeFileLineCount?: number;
} }
export function createTextModel(text: string, _options: IRelaxedTextModelCreationOptions = TextModel.DEFAULT_CREATION_OPTIONS, languageIdentifier: LanguageIdentifier = null, uri: URI = null): TextModel { export function createTextModel(text: string, _options: IRelaxedTextModelCreationOptions = TextModel.DEFAULT_CREATION_OPTIONS, languageIdentifier: LanguageIdentifier = null, uri: URI = null): TextModel {
@ -32,6 +34,8 @@ export function createTextModel(text: string, _options: IRelaxedTextModelCreatio
trimAutoWhitespace: (typeof _options.trimAutoWhitespace === 'undefined' ? TextModel.DEFAULT_CREATION_OPTIONS.trimAutoWhitespace : _options.trimAutoWhitespace), trimAutoWhitespace: (typeof _options.trimAutoWhitespace === 'undefined' ? TextModel.DEFAULT_CREATION_OPTIONS.trimAutoWhitespace : _options.trimAutoWhitespace),
defaultEOL: (typeof _options.defaultEOL === 'undefined' ? TextModel.DEFAULT_CREATION_OPTIONS.defaultEOL : _options.defaultEOL), defaultEOL: (typeof _options.defaultEOL === 'undefined' ? TextModel.DEFAULT_CREATION_OPTIONS.defaultEOL : _options.defaultEOL),
isForSimpleWidget: (typeof _options.isForSimpleWidget === 'undefined' ? TextModel.DEFAULT_CREATION_OPTIONS.isForSimpleWidget : _options.isForSimpleWidget), isForSimpleWidget: (typeof _options.isForSimpleWidget === 'undefined' ? TextModel.DEFAULT_CREATION_OPTIONS.isForSimpleWidget : _options.isForSimpleWidget),
largeFileSize: (typeof _options.largeFileSize === 'undefined' ? TextModel.DEFAULT_CREATION_OPTIONS.largeFileSize : _options.largeFileSize),
largeFileLineCount: (typeof _options.largeFileLineCount === 'undefined' ? TextModel.DEFAULT_CREATION_OPTIONS.largeFileLineCount : _options.largeFileLineCount),
}; };
return TextModel.createFromString(text, options, languageIdentifier, uri); return TextModel.createFromString(text, options, languageIdentifier, uri);
} }