in packages/blueprints/blueprint/src/resynthesis/merge-strategies/conflict-formatters.ts [36:71]
public static trimEnds(a: string, _o: string, b: string, options?: MergeConflictFormatterOptions): string {
const aLines = splitLines(a);
const bLines = splitLines(b);
const resultLines: string[] = [];
const minLength = Math.min(aLines.length, bLines.length);
for (let i = 0; i < minLength; i++) {
if (aLines[i] !== bLines[i]) {
break;
}
resultLines.push(aLines[i]);
}
const commonPrefixLength = resultLines.length;
let commonSuffix: string[] = [];
for (let i = 0; i < minLength - commonPrefixLength; i++) {
if (aLines[aLines.length - 1 - i] !== bLines[bLines.length - 1 - i]) {
break;
}
commonSuffix.push(aLines[aLines.length - 1 - i]);
}
const aConflictLines = aLines.slice(commonPrefixLength, aLines.length - commonSuffix.length);
const bConflictLines = bLines.slice(commonPrefixLength, bLines.length - commonSuffix.length);
if (aConflictLines.length || bConflictLines.length) {
resultLines.push(createConflictString(aConflictLines.join(''), bConflictLines.join(''), { ...options }));
}
if (commonSuffix.length) {
resultLines.push(...commonSuffix.reverse());
}
return resultLines.join('');
}