mirror of
https://github.com/Microsoft/vscode
synced 2024-10-30 21:06:57 +00:00
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:
commit
fbe4d3700b
6 changed files with 44 additions and 6 deletions
|
@ -668,6 +668,16 @@ const editorConfiguration: IConfigurationNode = {
|
|||
'default': true,
|
||||
'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': {
|
||||
'type': 'boolean',
|
||||
'default': true,
|
||||
|
|
|
@ -2204,7 +2204,9 @@ export const EDITOR_MODEL_DEFAULTS = {
|
|||
tabSize: 4,
|
||||
insertSpaces: true,
|
||||
detectIndentation: true,
|
||||
trimAutoWhitespace: true
|
||||
trimAutoWhitespace: true,
|
||||
largeFileSize: 20 * 1024 * 1024, // 20 MB
|
||||
largeFileLineCount: 300 * 1000 // 300K lines
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -396,6 +396,8 @@ export interface ITextModelCreationOptions {
|
|||
trimAutoWhitespace: boolean;
|
||||
defaultEOL: DefaultEndOfLine;
|
||||
isForSimpleWidget: boolean;
|
||||
largeFileSize: number;
|
||||
largeFileLineCount: number;
|
||||
}
|
||||
|
||||
export interface ITextModelUpdateOptions {
|
||||
|
|
|
@ -155,8 +155,6 @@ class TextModelSnapshot implements ITextSnapshot {
|
|||
export class TextModel extends Disposable implements model.ITextModel {
|
||||
|
||||
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 = {
|
||||
isForSimpleWidget: false,
|
||||
|
@ -165,6 +163,8 @@ export class TextModel extends Disposable implements model.ITextModel {
|
|||
detectIndentation: false,
|
||||
defaultEOL: model.DefaultEndOfLine.LF,
|
||||
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 {
|
||||
|
@ -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,
|
||||
// under no circumstances.
|
||||
this._isTooLargeForTokenization = (
|
||||
(bufferTextLength > TextModel.MODEL_TOKENIZATION_LIMIT)
|
||||
|| (bufferLineCount > TextModel.MANY_MANY_LINES)
|
||||
(bufferTextLength > creationOptions.largeFileSize)
|
||||
|| (bufferLineCount > creationOptions.largeFileLineCount)
|
||||
);
|
||||
|
||||
this._shouldSimplifyMode = (
|
||||
|
|
|
@ -197,6 +197,8 @@ interface IRawConfig {
|
|||
insertSpaces?: any;
|
||||
detectIndentation?: 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));
|
||||
}
|
||||
|
||||
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 {
|
||||
isForSimpleWidget: isForSimpleWidget,
|
||||
tabSize: tabSize,
|
||||
insertSpaces: insertSpaces,
|
||||
detectIndentation: detectIndentation,
|
||||
defaultEOL: newDefaultEOL,
|
||||
trimAutoWhitespace: trimAutoWhitespace
|
||||
trimAutoWhitespace: trimAutoWhitespace,
|
||||
largeFileSize: largeFileSize,
|
||||
largeFileLineCount: largeFileLineCount
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@ export interface IRelaxedTextModelCreationOptions {
|
|||
trimAutoWhitespace?: boolean;
|
||||
defaultEOL?: DefaultEndOfLine;
|
||||
isForSimpleWidget?: boolean;
|
||||
largeFileSize?: number;
|
||||
largeFileLineCount?: number;
|
||||
}
|
||||
|
||||
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),
|
||||
defaultEOL: (typeof _options.defaultEOL === 'undefined' ? TextModel.DEFAULT_CREATION_OPTIONS.defaultEOL : _options.defaultEOL),
|
||||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue