Skip to content

Commit

Permalink
Also enter the large file case based on line count, not just on file …
Browse files Browse the repository at this point in the history
…size (#30180)
  • Loading branch information
alexdima committed Jul 7, 2017
1 parent 398a6c5 commit 16151e8
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/vs/editor/common/model/textModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface ITextModelCreationData {
export class TextModel implements editorCommon.ITextModel {
private static MODEL_SYNC_LIMIT = 5 * 1024 * 1024; // 5 MB
private static MODEL_TOKENIZATION_LIMIT = 20 * 1024 * 1024; // 20 MB
private static MANY_MANY_LINES = 300 * 1000; // 300K lines

public static DEFAULT_CREATION_OPTIONS: editorCommon.ITextModelCreationOptions = {
tabSize: EDITOR_MODEL_DEFAULTS.tabSize,
Expand Down Expand Up @@ -103,12 +104,18 @@ export class TextModel implements editorCommon.ITextModel {

const textModelData = TextModel.resolveCreationData(rawTextSource, creationOptions);

this._shouldSimplifyMode = (textModelData.text.length > TextModel.MODEL_SYNC_LIMIT);

// !!! Make a decision in the ctor and permanently respect this decision !!!
// If a model is too large at construction time, it will never get tokenized,
// under no circumstances.
this._isTooLargeForTokenization = (textModelData.text.length > TextModel.MODEL_TOKENIZATION_LIMIT);
this._isTooLargeForTokenization = (
(textModelData.text.length > TextModel.MODEL_TOKENIZATION_LIMIT)
|| (textModelData.text.lines.length > TextModel.MANY_MANY_LINES)
);

this._shouldSimplifyMode = (
this._isTooLargeForTokenization
|| (textModelData.text.length > TextModel.MODEL_SYNC_LIMIT)
);

this._options = new editorCommon.TextModelResolvedOptions(textModelData.options);
this._constructLines(textModelData.text);
Expand Down

0 comments on commit 16151e8

Please sign in to comment.