diff --git a/src/search/query.ts b/src/search/query.ts index d632464..bbe595c 100644 --- a/src/search/query.ts +++ b/src/search/query.ts @@ -36,6 +36,10 @@ export class Query { }, []) } + public isEmpty(): boolean { + return this.segments.length === 0 + } + public segmentsToStr(): string { return this.segments.map(({ value }) => value).join(' ') } diff --git a/src/search/search-engine.ts b/src/search/search-engine.ts index 88c6d31..3f77b78 100644 --- a/src/search/search-engine.ts +++ b/src/search/search-engine.ts @@ -190,6 +190,10 @@ export class SearchEngine { query: Query, options?: Partial<{ singleFilePath: string | null }> ): Promise { + if (query.isEmpty()) { + previousResults = [] + return [] + } // Get the raw results let results: SearchResult[] if (settings.simpleSearch) {