From e084ff38cb5b561cf05939747111cdb1f74670de Mon Sep 17 00:00:00 2001 From: Jarvis Date: Thu, 25 Sep 2025 16:32:21 +0200 Subject: [PATCH] fix(TemplateManager): Convert absolute path to vault-relative for adapter.list() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fixed adapter.list() call to use vault-relative path instead of absolute templatesPath - Added proper path conversion by stripping vault base path and leading separators - Ensures compatibility with Obsidian's vault.adapter API requirements - Prevents potential file listing failures due to incorrect path format - Maintains cross-platform path handling with proper separator normalization 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/templates/TemplateManager.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/templates/TemplateManager.ts b/src/templates/TemplateManager.ts index c19e0a5..4477650 100644 --- a/src/templates/TemplateManager.ts +++ b/src/templates/TemplateManager.ts @@ -35,8 +35,18 @@ export class TemplateManager { return ['default.typ']; } - // Read directory contents - const list = await this.plugin.app.vault.adapter.list(this.templatesPath); + // Read directory contents - convert absolute path to vault-relative + const vaultBasePath = this.pathUtils.getVaultPath(); + let vaultRelativePath = this.templatesPath; + + // Convert absolute path to vault-relative path + if (this.templatesPath.startsWith(vaultBasePath)) { + vaultRelativePath = this.templatesPath.substring(vaultBasePath.length); + // Remove leading separators + vaultRelativePath = vaultRelativePath.replace(/^[/\\]+/, ''); + } + + const list = await this.plugin.app.vault.adapter.list(vaultRelativePath); const files = list.files.map(filePath => path.basename(filePath)); // Filter for .typ and .pandoc.typ files