Skip to content

Commit

Permalink
Clarify usage of TextModel.isTooLargeForHavingAMode() (#30180)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdima committed Jul 6, 2017
1 parent 80cfe84 commit 4f3327d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
7 changes: 0 additions & 7 deletions src/vs/editor/common/editorCommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -688,13 +688,6 @@ export interface ITextModel {
*/
isDisposed(): boolean;

/**
* No mode supports allowed on this model because it is simply too large.
* (even tokenization would cause too much memory pressure)
* @internal
*/
isTooLargeForHavingAMode(): boolean;

/**
* Only basic mode supports allowed on this model because it is simply too large.
* (tokenization is allowed and other basic supports)
Expand Down
13 changes: 6 additions & 7 deletions src/vs/editor/common/model/textModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,19 @@ export class TextModel implements editorCommon.ITextModel {
protected _mightContainNonBasicASCII: boolean;

private _shouldSimplifyMode: boolean;
private _shouldDenyMode: boolean;
protected readonly _isTooLargeForTokenization: boolean;

constructor(rawTextSource: IRawTextSource, creationOptions: editorCommon.ITextModelCreationOptions) {
this._eventEmitter = new OrderGuaranteeEventEmitter();

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

this._shouldSimplifyMode = (textModelData.text.length > TextModel.MODEL_SYNC_LIMIT);
this._shouldDenyMode = (textModelData.text.length > TextModel.MODEL_TOKENIZATION_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._options = new editorCommon.TextModelResolvedOptions(textModelData.options);
this._constructLines(textModelData.text);
Expand All @@ -117,11 +121,6 @@ export class TextModel implements editorCommon.ITextModel {
}
}

public isTooLargeForHavingAMode(): boolean {
this._assertNotDisposed();
return this._shouldDenyMode;
}

public isTooLargeForHavingARichMode(): boolean {
this._assertNotDisposed();
return this._shouldSimplifyMode;
Expand Down
2 changes: 1 addition & 1 deletion src/vs/editor/common/model/textModelWithTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
}

this._tokenizationSupport = null;
if (!this.isTooLargeForHavingAMode()) {
if (!this._isTooLargeForTokenization) {
this._tokenizationSupport = TokenizationRegistry.get(this._languageIdentifier.language);
}

Expand Down

0 comments on commit 4f3327d

Please sign in to comment.