提交 89721c99 编写于 作者: A Alex Dima

Fixes #66944: Tokenize viewport with debouncing after scrolling and when the...

Fixes #66944: Tokenize viewport with debouncing after scrolling and when the tokenization support has changed
上级 042e96cb
......@@ -315,6 +315,7 @@ export class TextModel extends Disposable implements model.ITextModel {
this._resetTokenizationState();
this.emitModelTokensChangedEvent({
tokenizationSupportChanged: true,
ranges: [{
fromLineNumber: 1,
toLineNumber: this.getLineCount()
......@@ -1841,6 +1842,7 @@ export class TextModel extends Disposable implements model.ITextModel {
public flushTokens(): void {
this._resetTokenizationState();
this.emitModelTokensChangedEvent({
tokenizationSupportChanged: false,
ranges: [{
fromLineNumber: 1,
toLineNumber: this.getLineCount()
......@@ -1923,6 +1925,7 @@ export class TextModel extends Disposable implements model.ITextModel {
this._resetTokenizationState();
this.emitModelTokensChangedEvent({
tokenizationSupportChanged: true,
ranges: [{
fromLineNumber: 1,
toLineNumber: this.getLineCount()
......
......@@ -82,6 +82,7 @@ export interface IModelDecorationsChangedEvent {
* An event describing that some ranges of lines have been tokenized (their tokens have changed).
*/
export interface IModelTokensChangedEvent {
readonly tokenizationSupportChanged: boolean;
readonly ranges: {
/**
* The start of the range (inclusive)
......
......@@ -500,6 +500,7 @@ export class ModelTokensChangedEventBuilder {
return null;
}
return {
tokenizationSupportChanged: false,
ranges: this._ranges
};
}
......
......@@ -23,6 +23,7 @@ import { IViewModelLinesCollection, IdentityLinesCollection, SplitLinesCollectio
import { ICoordinatesConverter, IOverviewRulerDecorations, IViewModel, MinimapLinesRenderingData, ViewLineData, ViewLineRenderingData, ViewModelDecoration } from 'vs/editor/common/viewModel/viewModel';
import { ViewModelDecorations } from 'vs/editor/common/viewModel/viewModelDecorations';
import { ITheme } from 'vs/platform/theme/common/themeService';
import { RunOnceScheduler } from 'vs/base/common/async';
const USE_IDENTITY_LINES_COLLECTION = true;
......@@ -31,6 +32,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
private readonly editorId: number;
private readonly configuration: editorCommon.IConfiguration;
private readonly model: ITextModel;
private readonly _tokenizeViewportSoon: RunOnceScheduler;
private hasFocus: boolean;
private viewportStartLine: number;
private viewportStartLineTrackedRange: string | null;
......@@ -38,7 +40,6 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
private readonly lines: IViewModelLinesCollection;
public readonly coordinatesConverter: ICoordinatesConverter;
public readonly viewLayout: ViewLayout;
private readonly decorations: ViewModelDecorations;
constructor(editorId: number, configuration: editorCommon.IConfiguration, model: ITextModel, scheduleAtNextAnimationFrame: (callback: () => void) => IDisposable) {
......@@ -47,6 +48,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
this.editorId = editorId;
this.configuration = configuration;
this.model = model;
this._tokenizeViewportSoon = this._register(new RunOnceScheduler(() => this.tokenizeViewport(), 50));
this.hasFocus = false;
this.viewportStartLine = -1;
this.viewportStartLineTrackedRange = null;
......@@ -80,6 +82,9 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
this.viewLayout = this._register(new ViewLayout(this.configuration, this.getLineCount(), scheduleAtNextAnimationFrame));
this._register(this.viewLayout.onDidScroll((e) => {
if (e.scrollTopChanged) {
this._tokenizeViewportSoon.schedule();
}
try {
const eventsCollector = this._beginEmit();
eventsCollector.emit(new viewEvents.ViewScrollChangedEvent(e));
......@@ -280,6 +285,10 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
} finally {
this._endEmit();
}
if (e.tokenizationSupportChanged) {
this._tokenizeViewportSoon.schedule();
}
}));
this._register(this.model.onDidChangeLanguageConfiguration((e) => {
......
......@@ -2263,6 +2263,7 @@ declare namespace monaco.editor {
* An event describing that some ranges of lines have been tokenized (their tokens have changed).
*/
export interface IModelTokensChangedEvent {
readonly tokenizationSupportChanged: boolean;
readonly ranges: {
/**
* The start of the range (inclusive)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册