parent
b4031c8e42
commit
aa19992ef1
1 changed files with 21 additions and 28 deletions
|
|
@ -100,41 +100,34 @@ export default class SideBySideRenderer {
|
||||||
left: this.makeHeaderHtml(block.header, file),
|
left: this.makeHeaderHtml(block.header, file),
|
||||||
right: this.makeHeaderHtml(''),
|
right: this.makeHeaderHtml(''),
|
||||||
};
|
};
|
||||||
let contextStash: (DiffLineContent & DiffLineContext)[] = []; // if white space are ignored, context should be relevant
|
|
||||||
let processContext = false;
|
|
||||||
this.applyLineGroupping(block).forEach(([contextLines, oldLines, newLines]) => {
|
this.applyLineGroupping(block).forEach(([contextLines, oldLines, newLines]) => {
|
||||||
if (oldLines.length && newLines.length && !contextLines.length) {
|
if (oldLines.length && newLines.length && !contextLines.length) {
|
||||||
this.applyRematchMatching(oldLines, newLines, matcher).map(([oldLines, newLines]) => {
|
this.applyRematchMatching(oldLines, newLines, matcher).map(([oldLines, newLines]) => {
|
||||||
const { left, right } = this.processChangedLines(file.isCombined, oldLines, newLines);
|
const { left, right } = this.processChangedLines(file.isCombined, oldLines, newLines);
|
||||||
fileHtml.left += left;
|
fileHtml.left += left;
|
||||||
fileHtml.right += right;
|
fileHtml.right += right;
|
||||||
if (!left && !right) {
|
|
||||||
contextStash = [];
|
|
||||||
processContext = false;
|
|
||||||
} else processContext = true;
|
|
||||||
});
|
});
|
||||||
} else if (contextLines.length || contextStash.length) {
|
} else if (contextLines.length) {
|
||||||
if (!processContext) contextStash = contextStash.concat(contextLines);
|
contextLines.forEach(line => {
|
||||||
else
|
const { prefix, content } = renderUtils.deconstructLine(line.content, file.isCombined);
|
||||||
contextLines.concat(processContext ? contextStash : []).forEach(line => {
|
const { left, right } = this.generateLineHtml(
|
||||||
const { prefix, content } = renderUtils.deconstructLine(line.content, file.isCombined);
|
{
|
||||||
const { left, right } = this.generateLineHtml(
|
type: renderUtils.CSSLineClass.CONTEXT,
|
||||||
{
|
prefix: prefix,
|
||||||
type: renderUtils.CSSLineClass.CONTEXT,
|
content: content,
|
||||||
prefix: prefix,
|
number: line.oldNumber,
|
||||||
content: content,
|
},
|
||||||
number: line.oldNumber,
|
{
|
||||||
},
|
type: renderUtils.CSSLineClass.CONTEXT,
|
||||||
{
|
prefix: prefix,
|
||||||
type: renderUtils.CSSLineClass.CONTEXT,
|
content: content,
|
||||||
prefix: prefix,
|
number: line.newNumber,
|
||||||
content: content,
|
},
|
||||||
number: line.newNumber,
|
);
|
||||||
},
|
fileHtml.left += left;
|
||||||
);
|
fileHtml.right += right;
|
||||||
fileHtml.left += left;
|
});
|
||||||
fileHtml.right += right;
|
|
||||||
});
|
|
||||||
} else if (oldLines.length || newLines.length) {
|
} else if (oldLines.length || newLines.length) {
|
||||||
const { left, right } = this.processChangedLines(file.isCombined, oldLines, newLines);
|
const { left, right } = this.processChangedLines(file.isCombined, oldLines, newLines);
|
||||||
fileHtml.left += left;
|
fileHtml.left += left;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue