提交 50b01b4a 编写于 作者: A Alex Dima

Update tokens when the buffer changes

上级 454e892a
...@@ -12,7 +12,7 @@ import { IModelChangedEvent, MirrorTextModel } from 'vs/editor/common/model/mirr ...@@ -12,7 +12,7 @@ import { IModelChangedEvent, MirrorTextModel } from 'vs/editor/common/model/mirr
import { TextMateWorkerHost } from 'vs/workbench/services/textMate/electron-browser/textMateService'; import { TextMateWorkerHost } from 'vs/workbench/services/textMate/electron-browser/textMateService';
import { TokenizationStateStore } from 'vs/editor/common/model/textModelTokens'; import { TokenizationStateStore } from 'vs/editor/common/model/textModelTokens';
import { IGrammar, StackElement, IRawTheme } from 'vscode-textmate'; import { IGrammar, StackElement, IRawTheme } from 'vscode-textmate';
import { MultilineTokensBuilder } from 'vs/editor/common/model/tokensStore'; import { MultilineTokensBuilder, countEOL } from 'vs/editor/common/model/tokensStore';
import { LineTokens } from 'vs/editor/common/core/lineTokens'; import { LineTokens } from 'vs/editor/common/core/lineTokens';
export interface IValidGrammarDefinitionDTO { export interface IValidGrammarDefinitionDTO {
...@@ -64,6 +64,16 @@ class TextMateWorkerModel extends MirrorTextModel { ...@@ -64,6 +64,16 @@ class TextMateWorkerModel extends MirrorTextModel {
this._resetTokenization(); this._resetTokenization();
} }
onEvents(e: IModelChangedEvent): void {
super.onEvents(e);
for (let i = 0; i < e.changes.length; i++) {
const change = e.changes[i];
const [eolCount] = countEOL(change.text);
this._tokenizationStateStore.applyEdits(change.range, eolCount);
}
this._ensureTokens();
}
private _resetTokenization(): void { private _resetTokenization(): void {
this._grammar = null; this._grammar = null;
this._tokenizationStateStore.flush(null); this._tokenizationStateStore.flush(null);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册