Skip to content

Commit

Permalink
Fix deleted file detection.
Browse files Browse the repository at this point in the history
  • Loading branch information
kitschpatrol committed Jun 16, 2024
1 parent aa25c52 commit 86f14bd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
sanitizeNamespace,
} from './utilities'
import sindreDebounce from 'debounce'
import path from 'node:path'
import {
Notice,
Plugin,
Expand Down Expand Up @@ -403,7 +404,8 @@ export default class YankiPlugin extends Plugin {
}

private isInsideWatchedFolders(fileOrFolder: TAbstractFile): boolean {
const folderPath = `${fileOrFolder instanceof TFolder ? fileOrFolder.path : fileOrFolder.parent?.path}/`
// Use dirname to find parent folder even if file has been deleted
const folderPath = `${fileOrFolder instanceof TFolder ? fileOrFolder.path : fileOrFolder.parent?.path ?? path.dirname(fileOrFolder.path)}/`
return this.getSanitizedFolders().some((watchedFolder) => folderPath.startsWith(watchedFolder))
}

Expand Down

0 comments on commit 86f14bd

Please sign in to comment.