MCPcopy Index your code
hub / github.com/banga/git-split-diffs / appendSpannedString

Method appendSpannedString

src/SpannedString.ts:68–99  ·  view source on GitHub ↗
(other: SpannedString<T>)

Source from the content-addressed store, hash-verified

66 }
67
68 appendSpannedString(other: SpannedString<T>): SpannedString<T> {
69 this._string = this._string.concat(other._string);
70
71 // The trailing span marker of this string and leading span marker of
72 // the other string will overlap, so we need to merge it
73 const spanMarkers = this._spanMarkers.concat(
74 new Array(other._spanMarkers.length - 1)
75 );
76 const overlappingSpanIndex = this._spanMarkers.length - 1;
77 for (
78 let otherIndex = 0;
79 otherIndex < other._spanMarkers.length;
80 otherIndex++
81 ) {
82 const otherSpans = other._spanMarkers[otherIndex];
83 if (otherSpans) {
84 const index = otherIndex + overlappingSpanIndex;
85 spanMarkers[index] = spanMarkers[index] ?? [];
86 spanMarkers[index]?.push(
87 ...otherSpans.map((span) => ({
88 ...span,
89 // Remap ids to avoid collisions
90 id: span.id + this._nextId,
91 }))
92 );
93 }
94 }
95 this._spanMarkers = spanMarkers;
96 this._nextId = this._nextId + other._nextId;
97
98 return this;
99 }
100
101 slice(
102 startIndex: number,

Callers 3

iterFormatHunkSplitFunction · 0.80
formatAndFitHunkLineFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected