- commit
- 52180a490b275fda9280f22e22de84d8eb7ed361
- parent
- e076b416c7acd504e67bcc4bebd62bd4189d9d8e
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2022-12-09 09:55
add unapply() helper
Diffstat
M | static/diff.js | 4 | ++++ |
M | static/pad.js | 5 | ++--- |
2 files changed, 6 insertions, 3 deletions
diff --git a/static/diff.js b/static/diff.js
@@ -37,6 +37,10 @@ export var apply = function(text, [start, end, before, after], selection) { 37 37 return text; 38 38 }; 39 39 -1 40 export var unapply = function(text, [start, end, before, after], selection) { -1 41 return apply(text, [start, end, after, before], selection); -1 42 } -1 43 40 44 export var diff = function(text1, text2, ctx) { 41 45 var start = 0; 42 46 var end = 0;
diff --git a/static/pad.js b/static/pad.js
@@ -41,9 +41,8 @@ var applyChanges = function(changes) { 41 41 var text = el.value; 42 42 var myChanges = [].concat(stagedChanges, localChanges); 43 4344 -1 for (var i = myChanges.length - 1; i >= 0; i--) {45 -1 change = myChanges[i];46 -1 text = diff.apply(text, [change[0], change[1], change[3], change[2]], selection);-1 44 for (change of myChanges.slice().reverse()) { -1 45 text = diff.unapply(text, change, selection); 47 46 } 48 47 49 48 for (change of changes) {