From b1c4a67629c42cebea6369e3c6258811d5003db6 Mon Sep 17 00:00:00 2001 From: Levi Rizki Saputra <42236775+levirs565@users.noreply.github.com> Date: Mon, 21 Aug 2023 21:24:56 +0700 Subject: [PATCH] fix: capitalization issue in lookup --- src/components/NoteComponent.svelte | 4 ++-- src/engine/note.ts | 6 +++--- src/modal/lookup.ts | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/NoteComponent.svelte b/src/components/NoteComponent.svelte index b2a06bf..49a748d 100644 --- a/src/components/NoteComponent.svelte +++ b/src/components/NoteComponent.svelte @@ -22,7 +22,7 @@ }; async function createCurrentNote() { - const path = note.getPath(); + const path = note.getPath(true); const plugin = getPlugin(); const file = await vault.createNote(path); openFile(plugin.app, file); @@ -36,7 +36,7 @@ function openLookup() { const { app, workspace } = getPlugin(); - new LookupModal(app, workspace, note.getPath()).open(); + new LookupModal(app, workspace, note.getPath(true)).open(); } function openMenu(e: MouseEvent) { diff --git a/src/engine/note.ts b/src/engine/note.ts index 196a843..3701574 100644 --- a/src/engine/note.ts +++ b/src/engine/note.ts @@ -38,15 +38,15 @@ export class Note { if (rescursive) this.children.forEach((child) => child.sortChildren(rescursive)); } - getPath() { + getPath(original = false) { const component: string[] = []; const notes = this.getPathNotes(); - if (notes.length === 1) return notes[0].name; + if (notes.length === 1) return original ? notes[0].originalName : notes[0].name; for (const note of notes) { if (!note.parent && note.name === "root") continue; - component.push(note.name); + component.push(original ? note.originalName : note.name); } return component.join("."); diff --git a/src/modal/lookup.ts b/src/modal/lookup.ts index 888b9eb..fc06bab 100644 --- a/src/modal/lookup.ts +++ b/src/modal/lookup.ts @@ -37,7 +37,7 @@ export class LookupModal extends SuggestModal { note, vault, }; - if (path === query) { + if (path === queryLowercase) { currentFoundExact = true; result.unshift(item); continue; @@ -53,7 +53,7 @@ export class LookupModal extends SuggestModal { foundExact = foundExact && currentFoundExact; } - if (!foundExact && query.trim().length > 0) result.unshift(null); + if (!foundExact && queryLowercase.trim().length > 0) result.unshift(null); return result; }