Skip to content

Build your personal knowledge base with Trilium Notes

remember last search in Jump To dialog when searching soon after the previous search

zadam574b71de63a1
diff --git a/src/public/app/dialogs/jump_to_note.js b/src/public/app/dialogs/jump_to_note.js
index 5128593f49..037fd5b2dd 100644
--- a/src/public/app/dialogs/jump_to_note.js
+++ b/src/public/app/dialogs/jump_to_note.js
@@ -6,9 +6,10 @@ const $dialog = $("#jump-to-note-dialog");
const $autoComplete = $("#jump-to-note-autocomplete");
const $showInFullTextButton = $("#show-in-full-text-button");
-export async function showDialog() {
- $autoComplete.val('');
+let lastOpenedTs = 0;
+const KEEP_LAST_SEARCH_FOR_X_SECONDS = 120;
+export async function showDialog() {
utils.openDialog($dialog);
noteAutocompleteService.initNoteAutocomplete($autoComplete, { hideGoToSelectedNoteButton: true })
@@ -20,7 +21,20 @@ export async function showDialog() {
appContext.tabManager.getActiveTabContext().setNote(suggestion.notePath);
});
- noteAutocompleteService.showRecentNotes($autoComplete);
+ // if you open the Jump To dialog soon after using it previously it can often mean that you
+ // actually want to search for the same thing (e.g. you opened the wrong note at first try)
+ // so we'll keep the content.
+ // if it's outside of this time limit then we assume it's a completely new search and show recent notes instead.
+ if (Date.now() - lastOpenedTs > KEEP_LAST_SEARCH_FOR_X_SECONDS * 1000) {
+ noteAutocompleteService.showRecentNotes($autoComplete);
+ }
+ else {
+ $autoComplete
+ .trigger('focus')
+ .trigger('select');
+ }
+
+ lastOpenedTs = Date.now();
}
function showInFullText(e) {