preserve context
This commit is contained in:
parent
6975f098f7
commit
c1d6701699
1 changed files with 28 additions and 21 deletions
|
|
@ -100,16 +100,23 @@ 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) {
|
} else if (contextLines.length || contextStash.length) {
|
||||||
contextLines.forEach(line => {
|
if (!processContext) contextStash = contextStash.concat(contextLines);
|
||||||
|
else
|
||||||
|
contextLines.concat(processContext ? contextStash : []).forEach(line => {
|
||||||
const { prefix, content } = renderUtils.deconstructLine(line.content, file.isCombined);
|
const { prefix, content } = renderUtils.deconstructLine(line.content, file.isCombined);
|
||||||
const { left, right } = this.generateLineHtml(
|
const { left, right } = this.generateLineHtml(
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue