Fixed a glitch that displayed the previous results when the query field was empty

This commit is contained in:
Simon Cambier
2022-11-10 21:19:10 +01:00
parent 2b0ade3a75
commit 5e7c2f7e5f
2 changed files with 8 additions and 0 deletions

View File

@@ -36,6 +36,10 @@ export class Query {
}, []) }, [])
} }
public isEmpty(): boolean {
return this.segments.length === 0
}
public segmentsToStr(): string { public segmentsToStr(): string {
return this.segments.map(({ value }) => value).join(' ') return this.segments.map(({ value }) => value).join(' ')
} }

View File

@@ -190,6 +190,10 @@ export class SearchEngine {
query: Query, query: Query,
options?: Partial<{ singleFilePath: string | null }> options?: Partial<{ singleFilePath: string | null }>
): Promise<ResultNote[]> { ): Promise<ResultNote[]> {
if (query.isEmpty()) {
previousResults = []
return []
}
// Get the raw results // Get the raw results
let results: SearchResult[] let results: SearchResult[]
if (settings.simpleSearch) { if (settings.simpleSearch) {