patch(issue #115): fixes merging deleted line(s) from lhs would munge rhs text (#117)

* patch(issue #115): fixes merging deleted line(s) from lhs would munge rhs text

* updated readme
This commit is contained in:
Jamie Peabody
2019-07-14 12:54:01 +01:00
committed by GitHub
parent 788c5ad17b
commit 90ab7f3f5e
4 changed files with 60 additions and 7 deletions

View File

@@ -1,13 +1,17 @@
# Changes
## 4.0.12
* patch: fixes issue #115 merging deleted line(s) from lhs would munge rhs text
* patch: fixes two typos in README.md
## 4.0.11
* fixes typo in example ajax.html
* patch: fixes typo in example ajax.html
## 4.0.10
* fixes bad 4.0.9 artifacts
* patch: fixes bad 4.0.9 artifacts
## 4.0.9
* #106: fixes merge edge-case with add
* patch: fixes issue #106 merge edge-case with add
## 4.0.8
* chore: updated webpack
@@ -17,15 +21,15 @@
## 4.0.6
* #89: fixes missing merge buttons
* patch: fixes issue #89 missing merge buttons
## 4.0.5
* #85: fixes XSS vulnerability with DOM id
* patch: fixes issue #85 XSS vulnerability with DOM id
## 4.0.2
* #83: fixes poor rendering performance
* patch: fixes issue #83 poor rendering performance
## 4.0.0

View File

@@ -1,6 +1,6 @@
{
"name": "mergely",
"version": "4.0.11",
"version": "4.0.12",
"description": "A javascript UI for diff/merge",
"directories": {
"doc": "doc",

View File

@@ -1504,6 +1504,7 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
odoc.replaceRange(text, CodeMirror.Pos(ofrom - 1, 0), CodeMirror.Pos(oto + 1, 0));
} else if ((oside === 'rhs' && change['op'] === 'd') || (oside === 'lhs' && change['op'] === 'a')) {
if (from > 0) {
fromlen = doc.getLine(from - 1).length + 1;
text = doc.getRange(CodeMirror.Pos(from - 1, fromlen), CodeMirror.Pos(to, tolen));
} else {
text = doc.getRange(CodeMirror.Pos(0, 0), CodeMirror.Pos(to + 1, 0));

View File

@@ -396,6 +396,54 @@ describe('mergely', function () {
rhs: 'a\nb\nx\nc',
dir: 'rhs',
name: 'merge rhs line 3 of length 1 and insert after line 2 of lhs'
},
{
lhs: '\ngood',
rhs: 'good',
dir: 'rhs',
name: 'lhs has deleted line at start'
},
{
lhs: '\na\nb\nc\ngood',
rhs: 'good',
dir: 'rhs',
name: 'lhs has multiple deleted lines at start'
},
{
lhs: 'good\n',
rhs: 'good',
dir: 'rhs',
name: 'lhs has deleted line at end (issue #115)'
},
{
lhs: 'good\na\nb\nc',
rhs: 'good',
dir: 'rhs',
name: 'lhs has multiple deleted lines at end (issue #115)'
},
{
lhs: 'good',
rhs: '\ngood',
dir: 'lhs',
name: 'rhs has added line at start'
},
{
lhs: 'good',
rhs: '\na\nb\nc\ngood',
dir: 'lhs',
name: 'rhs has multiple added lines at start'
},
{
lhs: 'good',
rhs: 'good\n',
dir: 'lhs',
name: 'rhs has added line at end'
},
{
lhs: 'good',
rhs: 'good\na\nb\nc',
dir: 'lhs',
name: 'rhs has multiple added lines at end'
}];
opts.forEach((opt, i) => {