Commit 5625e828 authored by Fatih Acet's avatar Fatih Acet

Check line lengths and fill missing lines with empty lines.

parent b0b5e9f1
...@@ -67,15 +67,38 @@ window.MergeConflictDataProvider = class MergeConflictDataProvider { ...@@ -67,15 +67,38 @@ window.MergeConflictDataProvider = class MergeConflictDataProvider {
} }
else { else {
const lineType = type || 'context'; const lineType = type || 'context';
file.parallelLines.left.push (this.getLineForParallelView(line, id, lineType)); file.parallelLines.left.push (this.getLineForParallelView(line, id, lineType));
file.parallelLines.right.push(this.getLineForParallelView(line, id, lineType)); file.parallelLines.right.push(this.getLineForParallelView(line, id, lineType, true));
} }
}); });
this.checkLineLengths(file);
}); });
}); });
} }
checkLineLengths(file) {
let { left, right } = file.parallelLines;
if (left.length !== right.length) {
if (left.length > right.length) {
const diff = left.length - right.length;
for (let i = 0; i < diff; i++) {
file.parallelLines.right.push({ lineType: 'emptyLine', richText: '' });
}
}
else {
const diff = right.length - left.length;
for (let i = 0; i < diff; i++) {
file.parallelLines.left.push({ lineType: 'emptyLine', richText: '' });
}
}
}
}
setInlineLines(data) { setInlineLines(data) {
data.files.forEach( (file) => { data.files.forEach( (file) => {
file.inlineLines = [] file.inlineLines = []
...@@ -208,14 +231,14 @@ window.MergeConflictDataProvider = class MergeConflictDataProvider { ...@@ -208,14 +231,14 @@ window.MergeConflictDataProvider = class MergeConflictDataProvider {
id, id,
lineType, lineType,
hasConflict, hasConflict,
isHead: hasConflict && isHead, isHead : hasConflict && isHead,
isOrigin: hasConflict && !isHead, isOrigin : hasConflict && !isHead,
hasMatch: lineType === 'match', hasMatch : lineType === 'match',
lineNumber: isHead ? new_line : old_line, lineNumber : isHead ? new_line : old_line,
section: isHead ? 'head' : 'origin', section : isHead ? 'head' : 'origin',
richText: rich_text, richText : rich_text,
isSelected: false, isSelected : false,
isUnselected: false isUnselected : false
} }
} }
......
//= require lib/vue //= require lib/vue
window.MergeConflictResolver = class MergeConflictResolver { window.MergeConflictResolver = class MergeConflictResolver {
constructor() { constructor() {
this.dataProvider = new MergeConflictDataProvider() this.dataProvider = new MergeConflictDataProvider()
this.initVue() this.initVue()
} }
initVue() { initVue() {
const that = this; const that = this;
this.vue = new Vue({ this.vue = new Vue({
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment