modelLineProjectionData.ts ×10

Frontier kind: Joint frontier

unlabeled · c_5b93378dda15

1 test · 35884 LOC · 207 files · introduces 1 test · 69 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
10 ranges69 lines · 1 files
Tests
1 test

Contains — complete concept membership

All code (extent)
4069 ranges35884 lines · 207 files · Browse complete extent
All tests (intent)
1 testBrowse 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.

1 test introduced at this concept.

Introduced code

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

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

src/vs/editor/common/modelLineProjectionData.ts 69 introduced LOC · 10 ranges

Open complete file

57
58 public getOutputLineCount(): number {
59 > return this.breakOffsets.length; modelLineProjectionData.ts
60 > }
61
62 public getMinOutputOffset(outputLineIndex: number): number {
168
169 public normalizeOutputPosition(outputLineIndex: number, outputOffset: number, affinity: PositionAffinity): OutputPosition {
170 > if (this.injectionOffsets !== null) { modelLineProjectionData.ts
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
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 > }
193
194 private outputPositionToOffsetInInputWithInjections(outputLineIndex: number, outputOffset: number): number {
195 > if (outputLineIndex > 0) { modelLineProjectionData.ts
196 > outputOffset = Math.max(0, outputOffset - this.wrappedTextIndentLength);
197 > }
198 > const result = (outputLineIndex > 0 ? this.breakOffsets[outputLineIndex - 1] : 0) + outputOffset;
199 > return result;
200 > }
201
202 private normalizeOffsetInInputWithInjectionsAroundInjections(offsetInInputWithInjections: number, affinity: PositionAffinity): number {
203 > const injectedText = this.getInjectedTextAtOffset(offsetInInputWithInjections); modelLineProjectionData.ts
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)) {
230 return result;
231 }
232 > } else if (affinity === PositionAffinity.Right || affinity === PositionAffinity.RightOfInjectedText) { modelLineProjectionData.ts
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
241 > } else if (affinity === PositionAffinity.Left || affinity === PositionAffinity.LeftOfInjectedText) {
242 // affinity is left
243 let result = injectedText.offsetInInputWithInjections;
252
253 assertNever(affinity);
255
256 public getInjectedText(outputLineIndex: number, outputOffset: number): InjectedText | null {
266
267 private getInjectedTextAtOffset(offsetInInputWithInjections: number): { injectedTextIndex: number; offsetInInputWithInjections: number; length: number } | undefined {
268 > const injectionOffsets = this.injectionOffsets; modelLineProjectionData.ts
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 > }
298 }
299