mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-07-31 08:12:51 +00:00
Fix crash with invalid patches
See https://github.com/Jermolene/TiddlyWiki5/pull/7290#issuecomment-1453155311 Thanks @yaisog
This commit is contained in:
parent
d5f0d834bc
commit
0c7e06a10c
@ -95,8 +95,16 @@ exports.makepatches = makeStringBinaryOperator(
|
||||
exports.applypatches = makeStringBinaryOperator(
|
||||
function(a,b) {
|
||||
var dmpObject = new dmp.diff_match_patch(),
|
||||
patches;
|
||||
try {
|
||||
patches = dmpObject.patch_fromText(b);
|
||||
return [dmpObject.patch_apply(patches,a)[0]];
|
||||
} catch(e) {
|
||||
}
|
||||
if(patches) {
|
||||
return [dmpObject.patch_apply(patches,a)[0]];
|
||||
} else {
|
||||
return [a];
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -0,0 +1,22 @@
|
||||
title: Filters/DiffMergePatch3
|
||||
description: Tests for diff-merge-patch derived operators
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
\define text1()
|
||||
the cat sat on the mat
|
||||
\end
|
||||
|
||||
\define patches()
|
||||
**NOT A VALID PATCH**
|
||||
\end
|
||||
|
||||
<$text text={{{ [<text1>applypatches<patches>] }}}/>
|
||||
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
the cat sat on the mat
|
Loading…
x
Reference in New Issue
Block a user