Skip to content

Commit

Permalink
Fix microsoft#55605. No tokenization when the line is long.
Browse files Browse the repository at this point in the history
  • Loading branch information
rebornix committed Sep 20, 2018
1 parent 5867dc7 commit 5db58b3
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/vs/editor/common/model/textModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import { TPromise } from 'vs/base/common/winjs.base';
import { IStringStream, ITextSnapshot } from 'vs/platform/files/common/files';
import { PieceTreeTextBufferBuilder } from 'vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBufferBuilder';

const CHEAP_TOKENIZATION_LENGTH_LIMIT = 2048;

function createTextBufferBuilder() {
return new PieceTreeTextBufferBuilder();
}
Expand Down Expand Up @@ -1852,7 +1854,19 @@ export class TextModel extends Disposable implements model.ITextModel {
}

public isCheapToTokenize(lineNumber: number): boolean {
return this._tokens.isCheapToTokenize(lineNumber);
if (!this._tokens.isCheapToTokenize(lineNumber)) {
return false;
}

if (lineNumber < this._tokens.inValidLineStartIndex + 1) {
return true;
}

if (this.getLineLength(lineNumber) < CHEAP_TOKENIZATION_LENGTH_LIMIT) {
return true;
}

return false;
}

public tokenizeIfCheap(lineNumber: number): void {
Expand Down

0 comments on commit 5db58b3

Please sign in to comment.