legacyLinesDiffComputer.ts ×15

Frontier kind: Code frontier

unlabeled · c_4367d79f1941

59 tests · 8144 LOC · 43 files · introduces 0 tests · 49 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
16 ranges49 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1312 ranges8144 lines · 43 files · Browse complete extent
All tests (intent)
59 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.

2 files ranked by introduced lines: 49 introduced LOC across 16 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/editor/common/diff/legacyLinesDiffComputer.ts 47 introduced LOC · 15 ranges

Open complete file

218
219 private _assertIndex(index: number, arr: number[]): void {
220 > if (index < 0 || index >= arr.length) { legacyLinesDiffComputer.ts
221 throw new Error(`Illegal index`);
222 }
224
225 public getElements(): Int32Array | number[] | string[] {
228
229 public getStartLineNumber(i: number): number {
230 > if (i > 0 && i === this._lineNumbers.length) { legacyLinesDiffComputer.ts
231 // the start line number of the element after the last element
232 // is the end line number of the last element
233 return this.getEndLineNumber(i - 1);
234 }
235 > this._assertIndex(i, this._lineNumbers); legacyLinesDiffComputer.ts
236 >
237 > return this._lineNumbers[i];
238 > }
239
240 public getEndLineNumber(i: number): number {
241 > if (i === -1) { legacyLinesDiffComputer.ts
242 // the end line number of the element before the first element
243 // is the start line number of the first element
244 return this.getStartLineNumber(i + 1);
245 }
246 > this._assertIndex(i, this._lineNumbers); legacyLinesDiffComputer.ts
247 >
248 > if (this._charCodes[i] === CharCode.LineFeed) {
249 return this._lineNumbers[i] + 1;
250 }
251 > return this._lineNumbers[i]; legacyLinesDiffComputer.ts
252 > }
253
254 public getStartColumn(i: number): number {
255 > if (i > 0 && i === this._columns.length) { legacyLinesDiffComputer.ts
256 // the start column of the element after the last element
257 // is the end column of the last element
258 return this.getEndColumn(i - 1);
259 }
260 > this._assertIndex(i, this._columns); legacyLinesDiffComputer.ts
261 > return this._columns[i];
262 > }
263
264 public getEndColumn(i: number): number {
265 > if (i === -1) { legacyLinesDiffComputer.ts
266 // the end column of the element before the first element
267 // is the start column of the first element
268 return this.getStartColumn(i + 1);
269 }
270 > this._assertIndex(i, this._columns); legacyLinesDiffComputer.ts
271 >
272 > if (this._charCodes[i] === CharCode.LineFeed) {
273 return 1;
274 }
275 > return this._columns[i] + 1; legacyLinesDiffComputer.ts
276 > }
277 }
278
310
311 public static createFromDiffChange(diffChange: IDiffChange, originalCharSequence: CharSequence, modifiedCharSequence: CharSequence): CharChange {
312 > const originalStartLineNumber = originalCharSequence.getStartLineNumber(diffChange.originalStart); legacyLinesDiffComputer.ts
313 > const originalStartColumn = originalCharSequence.getStartColumn(diffChange.originalStart);
314 > const originalEndLineNumber = originalCharSequence.getEndLineNumber(diffChange.originalStart + diffChange.originalLength - 1);
315 > const originalEndColumn = originalCharSequence.getEndColumn(diffChange.originalStart + diffChange.originalLength - 1);
316 >
317 > const modifiedStartLineNumber = modifiedCharSequence.getStartLineNumber(diffChange.modifiedStart);
318 > const modifiedStartColumn = modifiedCharSequence.getStartColumn(diffChange.modifiedStart);
319 > const modifiedEndLineNumber = modifiedCharSequence.getEndLineNumber(diffChange.modifiedStart + diffChange.modifiedLength - 1);
320 > const modifiedEndColumn = modifiedCharSequence.getEndColumn(diffChange.modifiedStart + diffChange.modifiedLength - 1);
321 >
322 > return new CharChange(
323 > originalStartLineNumber, originalStartColumn, originalEndLineNumber, originalEndColumn,
324 > modifiedStartLineNumber, modifiedStartColumn, modifiedEndLineNumber, modifiedEndColumn,
325 > );
326 > }
327 }
328
407
408 if (originalCharSequence.getElements().length > 0 && modifiedCharSequence.getElements().length > 0) {
409 > let rawChanges = computeDiff(originalCharSequence, modifiedCharSequence, continueCharDiff, true).changes; legacyLinesDiffComputer.ts
410 >
411 > if (shouldPostProcessCharChanges) {
412 rawChanges = postProcessCharChanges(rawChanges);
413 }
415 > charChanges = [];
416 > for (let i = 0, length = rawChanges.length; i < length; i++) {
417 > charChanges.push(CharChange.createFromDiffChange(rawChanges[i], originalCharSequence, modifiedCharSequence));
418 > }
419 > }
420 }
421
src/vs/base/common/diff/diff.ts 2 introduced LOC · 1 range

Open complete file

284 return [[], elements, false];
285 }
286 > diff.ts
287 > return [[], new Int32Array(elements), false];
288 }
289