Skip to content

Get rid of tokenizeViewportSoon in ViewModel and communicate modelVisibleRanges to the text model #178582

@hediet

Description

@hediet

Currently, the view model explicitly requests tokenizing some ranges in the text model every now and then (when scrolling, when the content changes, or when the tokenizationSupport changes).

Especially the handling of tokenizationSupport changes is weird - the text model tells the view port that the tokenizer changed, so that the viewport can re-request the text model to tokenize the viewport range (which does a heuristic tokenization initially, because background tokenization didn't catch up fully). This is because the text model itself doesn't know that it should focus on tokenizing the visible lines first (see here).

I suggest to implement this in a different way by inversing this mechanism: The tokenization implementation should know which ranges are currently visible (and when they change) and focus on those first.

The model already uses isAttachedToEditor to check if it is rendered by one or more text editors:

interface ITextModel {
  /** @internal */
  onBeforeAttached(): void;
  /** @internal */
  onBeforeDetached(): void;
}

Letting the model know which lines are visible just extends this idea. This could look like this:

interface ITextModel {
  /** @internal */
  onBeforeAttached(): IAttachedView;
  /** @internal */
  onBeforeDetached(view: IAttachedView): void;
}
interface IAttachedView {
  setVisibleRanges(ranges: LineRange[]): void;
}

Metadata

Metadata

Assignees

Labels

debtCode quality issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions