From 8c1788f259cf5e5b48b5f39c2c906f601e7acdc0 Mon Sep 17 00:00:00 2001 From: Felvesthe <23108389+Felvesthe@users.noreply.github.com> Date: Mon, 24 Mar 2025 20:17:36 +0100 Subject: [PATCH] Check if file exists in toggleNoteLock Signed-off-by: Felvesthe <23108389+Felvesthe@users.noreply.github.com> --- main.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main.ts b/main.ts index ee19670..a431477 100644 --- a/main.ts +++ b/main.ts @@ -67,6 +67,12 @@ export default class NoteLockerPlugin extends Plugin { await this.saveSettings(); const file = this.app.vault.getAbstractFileByPath(notePath); + + if (!file) { + new Notice("Error: Note not found"); + return; + } + const fileName = file instanceof TFile ? file.basename : notePath.split('/').pop()?.replace(/\..+$/, '') || notePath; const displayName = this.truncateFileName(fileName);