- commit
- cab2ad8df2a3b5d54d337af6812ffd60b2675ff8
- parent
- 347ad92c7108afa626ea1827b30e85e6b80e4949
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2020-05-12 06:49
roll back own changes before applying remote
Diffstat
M | static/pad.js | 20 | +++++++++++++++++--- |
1 files changed, 17 insertions, 3 deletions
diff --git a/static/pad.js b/static/pad.js
@@ -38,11 +38,25 @@ var sendChanges = utils.throttled(function() { 38 38 }, 500); 39 39 40 40 var applyChanges = function(changes) {41 -1 var text = el.value;-1 41 var change; -1 42 42 43 var selection = [el.selectionStart, el.selectionEnd, el.selectionDirection];43 -1 while (changes.length) {44 -1 text = context.apply(text, changes.shift(), selection);-1 44 var text = el.value; -1 45 var myChanges = [].concat(stagedChanges, localChanges); -1 46 -1 47 for (var i = myChanges.length - 1; i >= 0; i--) { -1 48 change = myChanges[i]; -1 49 text = context.apply(text, [change[0], change[1], change[3], change[2]], selection); 45 50 } -1 51 -1 52 for (change of changes) { -1 53 text = context.apply(text, change, selection); -1 54 } -1 55 -1 56 for (change of myChanges) { -1 57 text = context.apply(text, change, selection); -1 58 } -1 59 46 60 if (text !== el.value) { 47 61 var scrollTop = el.scrollTop; 48 62 el.value = text;