Skip to content

Commit ee870be

Browse files
committed
properly search the parent-folder-tree recursivly
1 parent 717eb53 commit ee870be

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

jsEngine/settings/Settings.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export class JsEnginePluginSettingTab extends PluginSettingTab {
7878

7979
const oldScripts = settings.startupScripts
8080
.map(file => vault.getFileByPath(file)!)
81-
.filter(file => !file.parent?.path.startsWith(settings.startupScriptsDirectory ?? ''));
81+
.filter(file => !this.isParentDir(file, settings.startupScriptsDirectory ?? '/'));
8282
if (oldScripts.length > 0) {
8383
this.containerEl.createEl('div', { cls: 'callout js-engine-settings-warning', text: 'These scripts are not in the Snippets Folder' });
8484
for (const file of oldScripts) {
@@ -112,6 +112,12 @@ export class JsEnginePluginSettingTab extends PluginSettingTab {
112112
return files.filter(f => f.extension == 'js').concat(folders.flatMap(dir => this.listJSfilesInDirectory(dir)));
113113
}
114114

115+
isParentDir(pathnode: TFile | TFolder, parent: string): boolean {
116+
if (pathnode.parent == null) return false;
117+
if (pathnode.parent.path == parent) return true;
118+
return this.isParentDir(pathnode.parent, parent);
119+
}
120+
115121
async toggleStartupScript(file: TFile, enable: boolean): Promise<void> {
116122
const settings = this.plugin.settings;
117123
if (enable) {

0 commit comments

Comments
 (0)