Skip to content

Commit b43d1bd

Browse files
committed
fix: diff changes undefined
1 parent 9819106 commit b43d1bd

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/extras/convert.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,9 @@ function rehype2note(rehype: HRoot) {
612612
}
613613

614614
function content2diff(oldStr: string, newStr: string) {
615-
return diffChars(oldStr, newStr);
615+
const diff = diffChars(oldStr, newStr);
616+
if (!diff) return [];
617+
return diff;
616618
}
617619

618620
async function md2html(md: string) {

src/modules/sync/diffWindow.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ export async function showSyncDiff(noteId: number, mdPath: string) {
2121
});
2222
const noteContent = await addon.api.convert.note2noteDiff(noteItem);
2323
ztoolkit.log(mdNoteContent, noteContent);
24-
const changes = await addon.api.convert.content2diff(
25-
noteContent,
26-
mdNoteContent,
27-
);
24+
const changes =
25+
(await addon.api.convert.content2diff(noteContent, mdNoteContent)) || [];
2826
ztoolkit.log("changes", changes);
2927

3028
const syncDate = new Date(syncStatus.lastsync);

0 commit comments

Comments
 (0)