modelLineProjectionData.ts ×18

Frontier kind: Code frontier

unlabeled · c_45d08514d0ad

27 tests · 15059 LOC · 43 files · introduces 0 tests · 97 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
18 ranges97 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1300 ranges15059 lines · 43 files · Browse complete extent
All tests (intent)
27 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: 97 introduced LOC across 18 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/editor/common/modelLineProjectionData.ts 97 introduced LOC · 18 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- modelLineProjectionData.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 { assertNever } from '../../base/common/assert.js';
7 > import { WrappingIndent } from './config/editorOptions.js';
8 > import { FontInfo } from './config/fontInfo.js';
9 > import { Position } from './core/position.js';
10 > import { InjectedTextCursorStops, InjectedTextOptions, PositionAffinity } from './model.js';
11 > import { LineInjectedText } from './textModelEvents.js';
12 >
13 > /**
14 > * *input*:
15 > * ```
16 > * xxxxxxxxxxxxxxxxxxxxxxxxxxx
17 > * ```
18 > *
19 > * -> Applying injections `[i...i]`, *inputWithInjections*:
20 > * ```
21 > * xxxxxx[iiiiiiiiii]xxxxxxxxxxxxxxxxx[ii]xxxx
22 > * ```
23 > *
24 > * -> breaking at offsets `|` in `xxxxxx[iiiiiii|iii]xxxxxxxxxxx|xxxxxx[ii]xxxx|`:
25 > * ```
26 > * xxxxxx[iiiiiii
27 > * iii]xxxxxxxxxxx
28 > * xxxxxx[ii]xxxx
29 > * ```
30 > *
31 > * -> applying wrappedTextIndentLength, *output*:
32 > * ```
33 > * xxxxxx[iiiiiii
34 > * iii]xxxxxxxxxxx
35 > * xxxxxx[ii]xxxx
36 > * ```
37 > */
38 > export class ModelLineProjectionData {
39 > constructor(
40 public injectionOffsets: number[] | null,
41 /**
55 ) {
56 }
58 > public getOutputLineCount(): number {
59 return this.breakOffsets.length;
60 }
62 > public getMinOutputOffset(outputLineIndex: number): number {
63 if (outputLineIndex > 0) {
64 return this.wrappedTextIndentLength;
66 return 0;
67 }
69 > public getLineLength(outputLineIndex: number): number {
70 // These offsets refer to model text with injected text.
71 const startOffset = outputLineIndex > 0 ? this.breakOffsets[outputLineIndex - 1] : 0;
78 return lineLength;
79 }
81 > public getMaxOutputOffset(outputLineIndex: number): number {
82 return this.getLineLength(outputLineIndex);
83 }
85 > public translateToInputOffset(outputLineIndex: number, outputOffset: number): number {
86 if (outputLineIndex > 0) {
87 outputOffset = Math.max(0, outputOffset - this.wrappedTextIndentLength);
108 return offsetInInput;
109 }
111 > public translateToOutputPosition(inputOffset: number, affinity: PositionAffinity = PositionAffinity.None): OutputPosition {
112 let inputOffsetInInputWithInjection = inputOffset;
113 if (this.injectionOffsets !== null) {
127 return this.offsetInInputWithInjectionsToOutputPosition(inputOffsetInInputWithInjection, affinity);
128 }
130 > private offsetInInputWithInjectionsToOutputPosition(offsetInInputWithInjections: number, affinity: PositionAffinity = PositionAffinity.None): OutputPosition {
131 let low = 0;
132 let high = this.breakOffsets.length - 1;
166 return new OutputPosition(mid, outputOffset);
167 }
169 > public normalizeOutputPosition(outputLineIndex: number, outputOffset: number, affinity: PositionAffinity): OutputPosition {
170 if (this.injectionOffsets !== null) {
171 const offsetInInputWithInjections = this.outputPositionToOffsetInInputWithInjections(outputLineIndex, outputOffset);
191 return new OutputPosition(outputLineIndex, outputOffset);
192 }
194 > private outputPositionToOffsetInInputWithInjections(outputLineIndex: number, outputOffset: number): number {
195 if (outputLineIndex > 0) {
196 outputOffset = Math.max(0, outputOffset - this.wrappedTextIndentLength);
199 return result;
200 }
202 > private normalizeOffsetInInputWithInjectionsAroundInjections(offsetInInputWithInjections: number, affinity: PositionAffinity): number {
203 const injectedText = this.getInjectedTextAtOffset(offsetInInputWithInjections);
204 if (!injectedText) {
253 assertNever(affinity);
254 }
256 > public getInjectedText(outputLineIndex: number, outputOffset: number): InjectedText | null {
257 const offset = this.outputPositionToOffsetInInputWithInjections(outputLineIndex, outputOffset);
258 const injectedText = this.getInjectedTextAtOffset(offset);
264 };
265 }
267 > private getInjectedTextAtOffset(offsetInInputWithInjections: number): { injectedTextIndex: number; offsetInInputWithInjections: number; length: number } | undefined {
268 const injectionOffsets = this.injectionOffsets;
269 const injectionOptions = this.injectionOptions;
296 return undefined;
297 }
299 >
300 function hasRightCursorStop(cursorStop: InjectedTextCursorStops | null | undefined): boolean {
301 if (cursorStop === null || cursorStop === undefined) { return true; }
306 return cursorStop === InjectedTextCursorStops.Left || cursorStop === InjectedTextCursorStops.Both;
307 }
309 > export class InjectedText {
310 > constructor(public readonly options: InjectedTextOptions) { }
311 > }
312 >
313 > export class OutputPosition {
314 > outputLineIndex: number;
315 > outputOffset: number;
316 >
317 > constructor(outputLineIndex: number, outputOffset: number) {
318 this.outputLineIndex = outputLineIndex;
319 this.outputOffset = outputOffset;
320 }
322 > toString(): string {
323 return `${this.outputLineIndex}:${this.outputOffset}`;
324 }
326 > toPosition(baseLineNumber: number): Position {
327 return new Position(baseLineNumber + this.outputLineIndex, this.outputOffset + 1);
328 }
330 >
331 > export interface ILineBreaksComputerContext {
332 > getLineContent(lineNumber: number): string;
333 > getLineInjectedText(lineNumber: number): LineInjectedText[] | null;
334 > }
335 >
336 > export interface ILineBreaksComputerFactory {
337 > createLineBreaksComputer(context: ILineBreaksComputerContext, fontInfo: FontInfo, tabSize: number, wrappingColumn: number, wrappingIndent: WrappingIndent, wordBreak: 'normal' | 'keepAll', wrapOnEscapedLineFeeds: boolean): ILineBreaksComputer;
338 > }
339 >
340 > export interface ILineBreaksComputer {
341 > /**
342 > * Pass in `previousLineBreakData` if the only difference is in breaking columns!!!
343 > */
344 > addRequest(lineNumber: number, previousLineBreakData: ModelLineProjectionData | null): void;
345 > finalize(): (ModelLineProjectionData | null)[];
346 > }