mirrorTextModel.ts ×10

Frontier kind: Code frontier

unlabeled · c_0c46986f2951

108 tests · 13621 LOC · 53 files · introduces 0 tests · 87 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
10 ranges87 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1352 ranges13621 lines · 53 files · Browse complete extent
All tests (intent)
108 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 87 introduced LOC across 10 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/editor/common/model/mirrorTextModel.ts 87 introduced LOC · 10 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- mirrorTextModel.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { splitLines } from '../../../base/common/strings.js';
7 > import { URI } from '../../../base/common/uri.js';
8 > import { Position } from '../core/position.js';
9 > import { IRange } from '../core/range.js';
10 > import { PrefixSumComputer } from './prefixSumComputer.js';
11 >
12 > export interface IModelContentChange {
13 > /**
14 > * The old range that got replaced.
15 > */
16 > readonly range: IRange;
17 > /**
18 > * The offset of the range that got replaced.
19 > */
20 > readonly rangeOffset: number;
21 > /**
22 > * The length of the range that got replaced.
23 > */
24 > readonly rangeLength: number;
25 > /**
26 > * The new text for the range.
27 > */
28 > readonly text: string;
29 > }
30 >
31 > export interface IModelChangedEvent {
32 > /**
33 > * The actual changes.
34 > */
35 > readonly changes: IModelContentChange[];
36 > /**
37 > * The (new) end-of-line character.
38 > */
39 > readonly eol: string;
40 > /**
41 > * The new version id the model has transitioned to.
42 > */
43 > readonly versionId: number;
44 > /**
45 > * Flag that indicates that this event was generated while undoing.
46 > */
47 > readonly isUndoing: boolean;
48 > /**
49 > * Flag that indicates that this event was generated while redoing.
50 > */
51 > readonly isRedoing: boolean;
52 > }
53 >
54 > export interface IMirrorTextModel {
55 > readonly version: number;
56 > }
57 >
58 > export class MirrorTextModel implements IMirrorTextModel {
59 >
60 > protected _uri: URI;
61 > protected _lines: string[];
62 > protected _eol: string;
63 > protected _versionId: number;
64 > protected _lineStarts: PrefixSumComputer | null;
65 > private _cachedTextValue: string | null;
66 >
67 > constructor(uri: URI, lines: string[], eol: string, versionId: number) {
68 this._uri = uri;
69 this._lines = lines;
73 this._cachedTextValue = null;
74 }
76 > dispose(): void {
77 this._lines.length = 0;
78 }
80 > get version(): number {
81 return this._versionId;
82 }
84 > getText(): string {
85 if (this._cachedTextValue === null) {
86 this._cachedTextValue = this._lines.join(this._eol);
88 return this._cachedTextValue;
89 }
91 > onEvents(e: IModelChangedEvent): void {
92 if (e.eol && e.eol !== this._eol) {
93 this._eol = e.eol;
105 this._cachedTextValue = null;
106 }
108 > protected _ensureLineStarts(): void {
109 if (!this._lineStarts) {
110 const eolLength = this._eol.length;
117 }
118 }
120 > /**
121 > * All changes to a line's text go through this method
122 > */
123 > private _setLineText(lineIndex: number, newValue: string): void {
124 this._lines[lineIndex] = newValue;
125 if (this._lineStarts) {
128 }
129 }
131 > private _acceptDeleteRange(range: IRange): void {
132
133 if (range.startLineNumber === range.endLineNumber) {
157 }
158 }
160 > private _acceptInsertText(position: Position, insertText: string): void {
161 if (insertText.length === 0) {
162 // Nothing to insert