src/vs/editor/common/modelLineProjectionData.ts

346 LOC · 266 covered · 80 uncovered · 44 ranges · 50 concepts · 12 introducers · 27 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

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 related-file, concept, and source links on this page.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the filemodelLineProjectionData.ts ×10 · 69 introduced LOCmodelLineProjectionData.…lineBreakData.test|title=Editor ViewModel - LineBreakData Injected Text 1 getInputOffsetOfOutputPosition is inverse of getOutputPositionOfInputOffset|occurrence=1, lineBreakData.test|title=Editor ViewModel - LineBreakData Injected Text 2 getInputOffsetOfOutputPosition is inverse of getOutputPositionOfInputOffset|occurrence=1, +1 · 0 introduced LOClineBreakData.test|title…modelLineProjectionData.ts ×1 · 7 introduced LOCmodelLineProjectionData.…modelLineProjectionData.ts ×1 · 12 introduced LOCmodelLineProjectionData.…modelLineProjectionData.ts ×1 · 2 introduced LOCmodelLineProjectionData.…modelLineProjectionData.ts ×1 · 2 introduced LOCmodelLineProjectionData.…modelLineProjectionData.ts ×2 · 9 introduced LOCmodelLineProjectionData.…modelLineProjectionData.ts ×2 · 13 introduced LOCmodelLineProjectionData.…monospaceLineBreaksComputer.ts ×4 · 13 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×2 · 7 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×2 · 8 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×2 · 8 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×1 · 2 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×15 · 206 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #75494: surrogate pairs overrun 1|occurrence=1 · 0 introduced LOCmonospaceLineBreaksCompu…Korean (CJK) text when setting normal|occurrence=1 · 0 introduced LOCKorean (CJK) text when s…monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #75494: surrogate pairs overrun 2|occurrence=1 · 0 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×1 · 6 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #16332: Scroll bar overlaying on top of text|occurrence=1 · 0 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #33366: Word wrap algorithm behaves differently around punctuation|occurrence=1, monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #152773: Word wrap algorithm behaves differently with bracket followed by comma|occurrence=1 · 0 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #35162: wrappingIndent not consistently working|occurrence=1, monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer MonospaceLineBreaksComputer - WrappingIndent.DeepIndent|occurrence=1 · 0 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×1 · 2 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer MonospaceLineBreaksComputer - WrappingIndent.Same|occurrence=1 · 0 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×1 · 3 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×1 · 3 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×1 · 4 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×1 · 3 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×1 · 3 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×2 · 6 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer MonospaceLineBreaksComputer - CJK and Kinsoku Shori|occurrence=1 · 0 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×3 · 16 introduced LOCmonospaceLineBreaksCompu…Korean (CJK) text when setting keepAll|occurrence=1 · 0 introduced LOCKorean (CJK) text when s…monospaceLineBreaksComputer.ts ×1 · 2 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×1 · 3 introduced LOCmonospaceLineBreaksCompu…modelLineProjectionData.ts ×1 · 1 introduced LOCmodelLineProjectionData.…monospaceLineBreaksComputer.ts ×1 · 4 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×3 · 17 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×2 · 4 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×4 · 14 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×1 · 2 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×2 · 10 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×1 · 2 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×2 · 4 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×1 · 3 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×1 · 2 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×24 · 170 introduced LOCmonospaceLineBreaksCompu…modelLineProjectionData.ts ×2 · 5 introduced LOCmodelLineProjectionData.…modelLineProjectionData.ts ×4 · 32 introduced LOCmodelLineProjectionData.…modelLineProjectionData.ts ×1 · 17 introduced LOCmodelLineProjectionData.…modelLineProjectionData.ts ×18 · 97 introduced LOCmodelLineProjectionData.…lineBreakData.test|title=Editor ViewModel - LineBreakData Basic|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/lineBreakData.test|title=Editor ViewModel - LineBreakData Basic|occurrence=1lineBreakData.test|title…lineBreakData.test|title=Editor ViewModel - LineBreakData Injected Text 1 getInputOffsetOfOutputPosition is inverse of getOutputPositionOfInputOffset|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/lineBreakData.test|title=Editor ViewModel - LineBreakData Injected Text 1 getInputOffsetOfOutputPosition is inverse of getOutputPositionOfInputOffset|occurrence=1lineBreakData.test|title…lineBreakData.test|title=Editor ViewModel - LineBreakData Injected Text 1 getInputOffsetOfOutputPosition|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/lineBreakData.test|title=Editor ViewModel - LineBreakData Injected Text 1 getInputOffsetOfOutputPosition|occurrence=1lineBreakData.test|title…lineBreakData.test|title=Editor ViewModel - LineBreakData Injected Text 1 getOutputPositionOfInputOffset|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/lineBreakData.test|title=Editor ViewModel - LineBreakData Injected Text 1 getOutputPositionOfInputOffset|occurrence=1lineBreakData.test|title…lineBreakData.test|title=Editor ViewModel - LineBreakData Injected Text 1 normalization|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/lineBreakData.test|title=Editor ViewModel - LineBreakData Injected Text 1 normalization|occurrence=1lineBreakData.test|title…lineBreakData.test|title=Editor ViewModel - LineBreakData Injected Text 2 getInputOffsetOfOutputPosition is inverse of getOutputPositionOfInputOffset|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/lineBreakData.test|title=Editor ViewModel - LineBreakData Injected Text 2 getInputOffsetOfOutputPosition is inverse of getOutputPositionOfInputOffset|occurrence=1lineBreakData.test|title…lineBreakData.test|title=Editor ViewModel - LineBreakData Injected Text 2 getInputOffsetOfOutputPosition|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/lineBreakData.test|title=Editor ViewModel - LineBreakData Injected Text 2 getInputOffsetOfOutputPosition|occurrence=1lineBreakData.test|title…lineBreakData.test|title=Editor ViewModel - LineBreakData Injected Text 3 getInputOffsetOfOutputPosition is inverse of getOutputPositionOfInputOffset|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/lineBreakData.test|title=Editor ViewModel - LineBreakData Injected Text 3 getInputOffsetOfOutputPosition is inverse of getOutputPositionOfInputOffset|occurrence=1lineBreakData.test|title…lineBreakData.test|title=Editor ViewModel - LineBreakData Injected Text 3 getInputOffsetOfOutputPosition|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/lineBreakData.test|title=Editor ViewModel - LineBreakData Injected Text 3 getInputOffsetOfOutputPosition|occurrence=1lineBreakData.test|title…monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer MonospaceLineBreaksComputer - CJK and Kinsoku Shori|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer MonospaceLineBreaksComputer - CJK and Kinsoku Shori|occurrence=1monospaceLineBreaksCompu…monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer MonospaceLineBreaksComputer - WrappingIndent.DeepIndent|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer MonospaceLineBreaksComputer - WrappingIndent.DeepIndent|occurrence=1monospaceLineBreaksCompu…monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer MonospaceLineBreaksComputer - WrappingIndent.Same|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer MonospaceLineBreaksComputer - WrappingIndent.Same|occurrence=1monospaceLineBreaksCompu…monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer MonospaceLineBreaksComputer incremental 1|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer MonospaceLineBreaksComputer incremental 1|occurrence=1monospaceLineBreaksCompu…monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer MonospaceLineBreaksComputer|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer MonospaceLineBreaksComputer|occurrence=1monospaceLineBreaksCompu…Korean (CJK) text when setting keepAll|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer Word break work well with Chinese/Japanese/Korean (CJK) text when setting keepAll|occurrence=1Korean (CJK) text when s…Korean (CJK) text when setting normal|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer Word break work well with Chinese/Japanese/Korean (CJK) text when setting normal|occurrence=1Korean (CJK) text when s…monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #110392: Occasional crash when resize with panel on the right|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #110392: Occasional crash when resize with panel on the right|occurrence=1monospaceLineBreaksCompu…monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #112382: Word wrap doesn't work well with control characters|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #112382: Word wrap doesn't work well with control characters|occurrence=1monospaceLineBreaksCompu…monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #152773: Word wrap algorithm behaves differently with bracket followed by comma|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #152773: Word wrap algorithm behaves differently with bracket followed by comma|occurrence=1monospaceLineBreaksCompu…monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #16332: Scroll bar overlaying on top of text|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #16332: Scroll bar overlaying on top of text|occurrence=1monospaceLineBreaksCompu…monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #258022: wrapOnEscapedLineFeeds: should work correctly after editor resize|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #258022: wrapOnEscapedLineFeeds: should work correctly after editor resize|occurrence=1monospaceLineBreaksCompu…monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #33366: Word wrap algorithm behaves differently around punctuation|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #33366: Word wrap algorithm behaves differently around punctuation|occurrence=1monospaceLineBreaksCompu…monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #35162: wrappingIndent not consistently working|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #35162: wrappingIndent not consistently working|occurrence=1monospaceLineBreaksCompu…monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #75494: surrogate pairs overrun 1|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #75494: surrogate pairs overrun 1|occurrence=1monospaceLineBreaksCompu…monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #75494: surrogate pairs overrun 2|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #75494: surrogate pairs overrun 2|occurrence=1monospaceLineBreaksCompu…monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #75494: surrogate pairs|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #75494: surrogate pairs|occurrence=1monospaceLineBreaksCompu…monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #95686: CRITICAL: loop forever on the monospaceLineBreaksComputer|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #95686: CRITICAL: loop forever on the monospaceLineBreaksComputer|occurrence=1monospaceLineBreaksCompu…Focused file · src/vs/editor/common/modelLineProjectionData.ts · 346 LOCcommon/modelLineProjecti…

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 > /*--------------------------------------------------------------------------------------------- modelLineProjectionData.ts ×18
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, modelLineProjectionData.ts ×1
41 > /**
42 > * `injectionOptions.length` must equal `injectionOffsets.length`
43 > */
44 > public injectionOptions: InjectedTextOptions[] | null,
45 > /**
46 > * Refers to offsets after applying injections to the source.
47 > * The last break offset indicates the length of the source after applying injections.
48 > */
49 > public breakOffsets: number[],
50 > /**
51 > * Refers to offsets after applying injections
52 > */
53 > public breakOffsetsVisibleColumn: number[],
54 > public wrappedTextIndentLength: number
55 > ) {
56 > }
58 > public getOutputLineCount(): number {
59 > return this.breakOffsets.length; modelLineProjectionData.ts ×10
60 > }
62 > public getMinOutputOffset(outputLineIndex: number): number {
63 if (outputLineIndex > 0) {
64 return this.wrappedTextIndentLength;
65 }
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;
72 const endOffset = this.breakOffsets[outputLineIndex];
73
74 let lineLength = endOffset - startOffset;
75 if (outputLineIndex > 0) {
76 lineLength += this.wrappedTextIndentLength;
77 }
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) { modelLineProjectionData.ts ×2
87 > outputOffset = Math.max(0, outputOffset - this.wrappedTextIndentLength);
88 > }
89 >
90 > const offsetInInputWithInjection = outputLineIndex === 0 ? outputOffset : this.breakOffsets[outputLineIndex - 1] + outputOffset;
91 > let offsetInInput = offsetInInputWithInjection;
92 >
93 > if (this.injectionOffsets !== null) {
94 > for (let i = 0; i < this.injectionOffsets.length; i++) {
95 > if (offsetInInput > this.injectionOffsets[i]) { modelLineProjectionData.ts ×2
96 > if (offsetInInput < this.injectionOffsets[i] + this.injectionOptions![i].content.length) {
97 > // `inputOffset` is within injected text modelLineProjectionData.ts ×1
98 > offsetInInput = this.injectionOffsets[i];
100 > offsetInInput -= this.injectionOptions![i].content.length;
101 > }
102 > } else {
103 > break;
104 > }
105 > }
107 >
108 > return offsetInInput;
109 > }
111 > public translateToOutputPosition(inputOffset: number, affinity: PositionAffinity = PositionAffinity.None): OutputPosition {
112 > let inputOffsetInInputWithInjection = inputOffset; modelLineProjectionData.ts ×2
113 > if (this.injectionOffsets !== null) {
114 > for (let i = 0; i < this.injectionOffsets.length; i++) { modelLineProjectionData.ts ×1
115 > if (inputOffset < this.injectionOffsets[i]) {
116 > break;
117 > }
118 >
119 > if (affinity !== PositionAffinity.Right && inputOffset === this.injectionOffsets[i]) {
120 > break;
121 > }
122 >
123 > inputOffsetInInputWithInjection += this.injectionOptions![i].content.length;
124 > }
125 > }
127 > return this.offsetInInputWithInjectionsToOutputPosition(inputOffsetInInputWithInjection, affinity);
128 > }
130 > private offsetInInputWithInjectionsToOutputPosition(offsetInInputWithInjections: number, affinity: PositionAffinity = PositionAffinity.None): OutputPosition {
131 > let low = 0; modelLineProjectionData.ts ×4
132 > let high = this.breakOffsets.length - 1;
133 > let mid = 0;
134 > let midStart = 0;
135 >
136 > while (low <= high) {
137 > mid = low + ((high - low) / 2) | 0;
138 >
139 > const midStop = this.breakOffsets[mid];
140 > midStart = mid > 0 ? this.breakOffsets[mid - 1] : 0;
141 >
142 > if (affinity === PositionAffinity.Left) {
143 > if (offsetInInputWithInjections <= midStart) { modelLineProjectionData.ts ×1
144 > high = mid - 1;
145 > } else if (offsetInInputWithInjections > midStop) {
146 > low = mid + 1;
147 > } else {
148 > break;
149 > }
151 > if (offsetInInputWithInjections < midStart) {
152 > high = mid - 1; modelLineProjectionData.ts ×1
153 > } else if (offsetInInputWithInjections >= midStop) { modelLineProjectionData.ts ×4
154 > low = mid + 1;
155 > } else {
156 > break;
157 > }
158 > }
159 > }
160 >
161 > let outputOffset = offsetInInputWithInjections - midStart;
162 > if (mid > 0) {
163 > outputOffset += this.wrappedTextIndentLength;
164 > }
165 >
166 > return new OutputPosition(mid, outputOffset);
167 > }
169 > public normalizeOutputPosition(outputLineIndex: number, outputOffset: number, affinity: PositionAffinity): OutputPosition {
170 > if (this.injectionOffsets !== null) { modelLineProjectionData.ts ×10
171 > const offsetInInputWithInjections = this.outputPositionToOffsetInInputWithInjections(outputLineIndex, outputOffset);
172 > const normalizedOffsetInUnwrappedLine = this.normalizeOffsetInInputWithInjectionsAroundInjections(offsetInInputWithInjections, affinity);
173 > if (normalizedOffsetInUnwrappedLine !== offsetInInputWithInjections) {
174 > // injected text caused a change
175 > return this.offsetInInputWithInjectionsToOutputPosition(normalizedOffsetInUnwrappedLine, affinity);
176 > }
177 > }
178 >
179 > if (affinity === PositionAffinity.Left) {
180 if (outputLineIndex > 0 && outputOffset === this.getMinOutputOffset(outputLineIndex)) {
181 return new OutputPosition(outputLineIndex - 1, this.getMaxOutputOffset(outputLineIndex - 1));
182 }
183 }
184 > else if (affinity === PositionAffinity.Right) { modelLineProjectionData.ts ×10
185 > const maxOutputLineIndex = this.getOutputLineCount() - 1;
186 > if (outputLineIndex < maxOutputLineIndex && outputOffset === this.getMaxOutputOffset(outputLineIndex)) {
187 return new OutputPosition(outputLineIndex + 1, this.getMinOutputOffset(outputLineIndex + 1));
188 }
190 >
191 > return new OutputPosition(outputLineIndex, outputOffset);
192 > }
194 > private outputPositionToOffsetInInputWithInjections(outputLineIndex: number, outputOffset: number): number {
195 > if (outputLineIndex > 0) { modelLineProjectionData.ts ×10
196 > outputOffset = Math.max(0, outputOffset - this.wrappedTextIndentLength);
197 > }
198 > const result = (outputLineIndex > 0 ? this.breakOffsets[outputLineIndex - 1] : 0) + outputOffset;
199 > return result;
200 > }
202 > private normalizeOffsetInInputWithInjectionsAroundInjections(offsetInInputWithInjections: number, affinity: PositionAffinity): number {
203 > const injectedText = this.getInjectedTextAtOffset(offsetInInputWithInjections); modelLineProjectionData.ts ×10
204 > if (!injectedText) {
205 > return offsetInInputWithInjections;
206 > }
207 >
208 > if (affinity === PositionAffinity.None) {
209 if (offsetInInputWithInjections === injectedText.offsetInInputWithInjections + injectedText.length
210 && hasRightCursorStop(this.injectionOptions![injectedText.injectedTextIndex].cursorStops)) {
211 return injectedText.offsetInInputWithInjections + injectedText.length;
212 } else {
213 let result = injectedText.offsetInInputWithInjections;
214 if (hasLeftCursorStop(this.injectionOptions![injectedText.injectedTextIndex].cursorStops)) {
215 return result;
216 }
217
218 let index = injectedText.injectedTextIndex - 1;
219 while (index >= 0 && this.injectionOffsets![index] === this.injectionOffsets![injectedText.injectedTextIndex]) {
220 if (hasRightCursorStop(this.injectionOptions![index].cursorStops)) {
221 break;
222 }
223 result -= this.injectionOptions![index].content.length;
224 if (hasLeftCursorStop(this.injectionOptions![index].cursorStops)) {
225 break;
226 }
227 index--;
228 }
229
230 return result;
231 }
232 > } else if (affinity === PositionAffinity.Right || affinity === PositionAffinity.RightOfInjectedText) { modelLineProjectionData.ts ×10
233 > let result = injectedText.offsetInInputWithInjections + injectedText.length;
234 > let index = injectedText.injectedTextIndex;
235 > // traverse all injected text that touch each other
236 > while (index + 1 < this.injectionOffsets!.length && this.injectionOffsets![index + 1] === this.injectionOffsets![index]) {
237 result += this.injectionOptions![index + 1].content.length;
238 index++;
239 }
240 > return result; modelLineProjectionData.ts ×10
241 > } else if (affinity === PositionAffinity.Left || affinity === PositionAffinity.LeftOfInjectedText) {
242 // affinity is left
243 let result = injectedText.offsetInInputWithInjections;
244 let index = injectedText.injectedTextIndex;
245 // traverse all injected text that touch each other
246 while (index - 1 >= 0 && this.injectionOffsets![index - 1] === this.injectionOffsets![index]) {
247 result -= this.injectionOptions![index - 1].content.length;
248 index--;
249 }
250 return result;
251 }
252
253 assertNever(affinity);
256 > public getInjectedText(outputLineIndex: number, outputOffset: number): InjectedText | null {
257 const offset = this.outputPositionToOffsetInInputWithInjections(outputLineIndex, outputOffset);
258 const injectedText = this.getInjectedTextAtOffset(offset);
259 if (!injectedText) {
260 return null;
261 }
262 return {
263 options: this.injectionOptions![injectedText.injectedTextIndex]
264 };
265 }
267 > private getInjectedTextAtOffset(offsetInInputWithInjections: number): { injectedTextIndex: number; offsetInInputWithInjections: number; length: number } | undefined {
268 > const injectionOffsets = this.injectionOffsets; modelLineProjectionData.ts ×10
269 > const injectionOptions = this.injectionOptions;
270 >
271 > if (injectionOffsets !== null) {
272 > let totalInjectedTextLengthBefore = 0;
273 > for (let i = 0; i < injectionOffsets.length; i++) {
274 > const length = injectionOptions![i].content.length;
275 > const injectedTextStartOffsetInInputWithInjections = injectionOffsets[i] + totalInjectedTextLengthBefore;
276 > const injectedTextEndOffsetInInputWithInjections = injectionOffsets[i] + totalInjectedTextLengthBefore + length;
277 >
278 > if (injectedTextStartOffsetInInputWithInjections > offsetInInputWithInjections) {
279 > // Injected text starts later.
280 > break; // All later injected texts have an even larger offset.
281 > }
282 >
283 > if (offsetInInputWithInjections <= injectedTextEndOffsetInInputWithInjections) {
284 > // Injected text ends after or with the given position (but also starts with or before it).
285 > return {
286 > injectedTextIndex: i,
287 > offsetInInputWithInjections: injectedTextStartOffsetInInputWithInjections,
288 > length
289 > };
290 > }
291 >
292 > totalInjectedTextLengthBefore += length;
293 > }
294 > }
295 >
296 > return undefined;
297 > }
299 >
300 function hasRightCursorStop(cursorStop: InjectedTextCursorStops | null | undefined): boolean {
301 if (cursorStop === null || cursorStop === undefined) { return true; }
302 return cursorStop === InjectedTextCursorStops.Right || cursorStop === InjectedTextCursorStops.Both;
303 }
304 function hasLeftCursorStop(cursorStop: InjectedTextCursorStops | null | undefined): boolean {
305 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; modelLineProjectionData.ts ×4
319 > this.outputOffset = outputOffset;
320 > }
322 > toString(): string {
323 > return `${this.outputLineIndex}:${this.outputOffset}`; modelLineProjectionData.ts ×1
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 > }