diff --git a/src/public/app/types.d.ts b/src/public/app/types.d.ts index 774985177..cab82d103 100644 --- a/src/public/app/types.d.ts +++ b/src/public/app/types.d.ts @@ -95,7 +95,7 @@ declare global { className: string; separateWordSearch: boolean; caseSensitive: boolean; - done: () => void; + done?: () => void; }); unmark(opts?: { done: () => void; diff --git a/src/public/app/widgets/find.ts b/src/public/app/widgets/find.ts index c208128fb..2505c5a85 100644 --- a/src/public/app/widgets/find.ts +++ b/src/public/app/widgets/find.ts @@ -305,7 +305,10 @@ export default class FindWidget extends NoteContextAwareWidget { const matchCase = this.$caseSensitiveCheckbox.prop("checked"); const wholeWord = this.$matchWordsCheckbox.prop("checked"); - const { totalFound, currentFound } = await this.handler?.performFind(searchTerm, matchCase, wholeWord); + if (!this.handler) { + return; + } + const { totalFound, currentFound } = await this.handler.performFind(searchTerm, matchCase, wholeWord); this.$totalFound.text(totalFound); this.$currentFound.text(currentFound); diff --git a/src/public/app/widgets/find_in_code.ts b/src/public/app/widgets/find_in_code.ts index d29cd67ce..63081bb0b 100644 --- a/src/public/app/widgets/find_in_code.ts +++ b/src/public/app/widgets/find_in_code.ts @@ -38,7 +38,7 @@ export default class FindInCode { // See https://codemirror.net/addon/search/searchcursor.js for tips const codeEditor = await this.getCodeEditor(); if (!codeEditor) { - return; + return { totalFound: 0, currentFound: 0 }; } const doc = codeEditor.doc;