ignore white spaces in side by side renderer
This commit is contained in:
parent
e5c813949f
commit
e2b70660df
1 changed files with 26 additions and 1 deletions
|
|
@ -203,6 +203,28 @@ export default class SideBySideRenderer {
|
||||||
return doMatching ? matcher(oldLines, newLines) : [[oldLines, newLines]];
|
return doMatching ? matcher(oldLines, newLines) : [[oldLines, newLines]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ignoreWhiteSpaces(oldLines: DiffLine[], newLines: DiffLine[]): DiffLine[][] {
|
||||||
|
const maxLinesNumber = Math.max(oldLines.length, newLines.length);
|
||||||
|
const oldLinesProcessed = [];
|
||||||
|
const newLinesProcessed = [];
|
||||||
|
for (let i = 0; i < maxLinesNumber; i++) {
|
||||||
|
const oldLine = oldLines[i];
|
||||||
|
const newLine = newLines[i];
|
||||||
|
if (oldLine != undefined && newLine != undefined && oldLine.oldNumber == newLine.newNumber) {
|
||||||
|
const oldContent = oldLine.content.substr(1);
|
||||||
|
const newContent = newLine.content.substr(1);
|
||||||
|
|
||||||
|
const spaceMatch = /\s/g;
|
||||||
|
if (oldContent != newContent && oldContent.replace(spaceMatch, '') == newContent.replace(spaceMatch, ''))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
oldLinesProcessed.push(oldLine);
|
||||||
|
newLinesProcessed.push(newLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [oldLinesProcessed, newLinesProcessed];
|
||||||
|
}
|
||||||
|
|
||||||
makeHeaderHtml(blockHeader: string, file?: DiffFile): string {
|
makeHeaderHtml(blockHeader: string, file?: DiffFile): string {
|
||||||
return this.hoganUtils.render(genericTemplatesPath, 'block-header', {
|
return this.hoganUtils.render(genericTemplatesPath, 'block-header', {
|
||||||
CSSLineClass: renderUtils.CSSLineClass,
|
CSSLineClass: renderUtils.CSSLineClass,
|
||||||
|
|
@ -217,8 +239,11 @@ export default class SideBySideRenderer {
|
||||||
right: '',
|
right: '',
|
||||||
left: '',
|
left: '',
|
||||||
};
|
};
|
||||||
|
const [filteredOldLines, filteredNewLines] = this.config?.ignoreWhiteSpaces
|
||||||
|
? this.ignoreWhiteSpaces(oldLines, newLines)
|
||||||
|
: [oldLines, newLines];
|
||||||
|
|
||||||
const maxLinesNumber = Math.max(oldLines.length, newLines.length);
|
const maxLinesNumber = Math.max(filteredOldLines.length, filteredNewLines.length);
|
||||||
for (let i = 0; i < maxLinesNumber; i++) {
|
for (let i = 0; i < maxLinesNumber; i++) {
|
||||||
const oldLine = oldLines[i];
|
const oldLine = oldLines[i];
|
||||||
const newLine = newLines[i];
|
const newLine = newLines[i];
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue