228
this.innerChanges = innerChanges;
229
}
231
>
public override flip(): DetailedLineRangeMapping {
232
return new DetailedLineRangeMapping(this.modified, this.original, this.innerChanges?.map(c => c.flip()));
233
}
235
>
public withInnerChangesFromLineRanges(): DetailedLineRangeMapping {
236
return new DetailedLineRangeMapping(this.original, this.modified, [this.toRangeMapping()]);
237
}
239
>
240
>
/**
241
>
* Maps a range in the original text model to a range in the modified text model.
242
>
*/
243
>
export class RangeMapping {
244
>
public static fromEdit(edit: TextEdit): RangeMapping[] {
245
const newRanges = edit.getNewRanges();
246
const result = edit.replacements.map((e, idx) => new RangeMapping(e.range, newRanges[idx]));
247
return result;
248
}
250
>
public static fromEditJoin(edit: TextEdit): RangeMapping {
251
const newRanges = edit.getNewRanges();
252
const result = edit.replacements.map((e, idx) => new RangeMapping(e.range, newRanges[idx]));
253
return RangeMapping.join(result);
254
}
256
>
public static join(rangeMappings: RangeMapping[]): RangeMapping {
257
if (rangeMappings.length === 0) {
258
throw new BugIndicatingError('Cannot join an empty list of range mappings');