Check if file exists in toggleNoteLock

Signed-off-by: Felvesthe <23108389+Felvesthe@users.noreply.github.com>
This commit is contained in:
Felvesthe 2025-03-24 20:17:36 +01:00
parent 1dde3618c7
commit 8c1788f259

View file

@ -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);