editableTextModelTestUtils.ts ×6

Frontier kind: Code frontier

unlabeled · c_b3a323e505ac

45 tests · 41370 LOC · 241 files · introduces 0 tests · 54 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
6 ranges54 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
5112 ranges41370 lines · 241 files · Browse complete extent
All tests (intent)
45 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: 54 introduced LOC across 6 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/editor/test/common/model/editableTextModelTestUtils.ts 54 introduced LOC · 6 ranges

Open complete file

53 }
54
55 > function assertOneDirectionLineMapping(model: TextModel, direction: AssertDocumentLineMappingDirection, msg: string): void { editableTextModelTestUtils.ts
56 > const allText = model.getValue();
57 >
58 > let line = 1, column = 1, previousIsCarriageReturn = false;
59 > for (let offset = 0; offset <= allText.length; offset++) {
60 > // The position coordinate system cannot express the position between \r and \n
61 > const position: Position = new Position(line, column + (previousIsCarriageReturn ? -1 : 0));
62 >
63 > if (direction === AssertDocumentLineMappingDirection.OffsetToPosition) {
64 > const actualPosition = model.getPositionAt(offset);
65 > assert.strictEqual(actualPosition.toString(), position.toString(), msg + ' - getPositionAt mismatch for offset ' + offset);
66 > } else {
67 > // The position coordinate system cannot express the position between \r and \n
68 > const expectedOffset: number = offset + (previousIsCarriageReturn ? -1 : 0);
69 > const actualOffset = model.getOffsetAt(position);
70 > assert.strictEqual(actualOffset, expectedOffset, msg + ' - getOffsetAt mismatch for position ' + position.toString());
71 > }
72 >
73 > if (allText.charAt(offset) === '\n') {
74 line++;
75 column = 1;
77 > column++;
78 > }
79 >
80 > previousIsCarriageReturn = (allText.charAt(offset) === '\r');
81 > }
82 > }
83
84 > function assertLineMapping(model: TextModel, msg: string): void { editableTextModelTestUtils.ts
85 > assertOneDirectionLineMapping(model, AssertDocumentLineMappingDirection.PositionToOffset, msg);
86 > assertOneDirectionLineMapping(model, AssertDocumentLineMappingDirection.OffsetToPosition, msg);
87 > }
88
89
90 export function assertSyncedModels(text: string, callback: (model: TextModel, assertMirrorModels: () => void) => void, setup: ((model: TextModel) => void) | null = null): void {
91 > const model = createTextModel(text); editableTextModelTestUtils.ts
92 > model.setEOL(EndOfLineSequence.LF);
93 > assertLineMapping(model, 'model');
94 >
95 > if (setup) {
96 setup(model);
97 assertLineMapping(model, 'model');
98 }
100 > const mirrorModel2 = new MirrorTextModel(null!, model.getLinesContent(), model.getEOL(), model.getVersionId());
101 > let mirrorModel2PrevVersionId = model.getVersionId();
102 >
103 > const disposable = model.onDidChangeContent((e: IModelContentChangedEvent) => {
104 const versionId = e.versionId;
105 if (versionId < mirrorModel2PrevVersionId) {
108 mirrorModel2PrevVersionId = versionId;
109 mirrorModel2.onEvents(e);
111 >
112 > const assertMirrorModels = () => {
113 > assertLineMapping(model, 'model');
114 > assert.strictEqual(mirrorModel2.getText(), model.getValue(), 'mirror model 2 text OK');
115 > assert.strictEqual(mirrorModel2.version, model.getVersionId(), 'mirror model 2 version OK');
116 > };
117 >
118 > callback(model, assertMirrorModels);
119 >
120 > disposable.dispose();
121 > model.dispose();
122 > mirrorModel2.dispose();
123 > }