Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit fd53e35

Browse files
committed
feat(autocomplete): don't search unless length is 3
1 parent 766b072 commit fd53e35

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/public/app/services/note_autocomplete.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,14 @@ async function autocompleteSource(term: string, cb: (rows: Suggestion[]) => void
7070
}
7171

7272
const activeNoteId = appContext.tabManager.getActiveContextNoteId();
73+
const length = term.trim().length;
7374

74-
let results: Suggestion[] = await server.get<Suggestion[]>(`autocomplete?query=${encodeURIComponent(term)}&activeNoteId=${activeNoteId}&fastSearch=${fastSearch}`);
75-
if (term.trim().length >= 1 && options.allowCreatingNotes) {
75+
let results: Suggestion[] = [];
76+
if (length >= 3) {
77+
results = await server.get<Suggestion[]>(`autocomplete?query=${encodeURIComponent(term)}&activeNoteId=${activeNoteId}&fastSearch=${fastSearch}`);
78+
}
79+
80+
if (length >= 1 && options.allowCreatingNotes) {
7681
results = [
7782
{
7883
action: "create-note",
@@ -83,7 +88,7 @@ async function autocompleteSource(term: string, cb: (rows: Suggestion[]) => void
8388
].concat(results);
8489
}
8590

86-
if (term.trim().length >= 1 && options.allowJumpToSearchNotes) {
91+
if (length >= 1 && options.allowJumpToSearchNotes) {
8792
results = results.concat([
8893
{
8994
action: "search-notes",

0 commit comments

Comments
 (0)