Skip to content

Fix relative catalog path resolution with workspace folder tokens#13

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/fix-12
Draft

Fix relative catalog path resolution with workspace folder tokens#13
Copilot wants to merge 4 commits intomainfrom
copilot/fix-12

Conversation

Copy link

Copilot AI commented Sep 16, 2025

The catalog path resolution in discoverRepositories was not properly handling VS Code workspace folder tokens in relative paths. Users could not use ${workspaceFolder} or ${workspaceFolder:name} tokens in their catalog configuration, limiting flexibility for multi-workspace scenarios.

Problem

The existing implementation only handled basic relative paths by joining them with the first workspace folder:

// Old logic - treats tokens as literal text
if (path.isAbsolute(catalogPath)) {
    absoluteCatalogPath = catalogPath;
} else {
    const workspaceFolder = vscode.workspace.workspaceFolders?.[0];
    absoluteCatalogPath = path.join(workspaceFolder.uri.fsPath, catalogPath);
}

This meant configurations like this would fail:

{
  "copilotCatalog.catalogDirectory": {
    "${workspaceFolder}/team-catalog": "Team Resources",
    "${workspaceFolder:shared-resources}/global-catalog": "Shared Assets"
  }
}

Solution

Modified discoverRepositories to use the existing resolveWorkspacePath function that already supported workspace folder token expansion. The fix:

  1. Enhanced function signature: Added optional resolveWorkspacePath parameter
  2. Improved path resolution: Use token expansion when available, with fallback to original logic
  3. Updated call sites: Pass the resolveWorkspacePath function to both calls

Key Benefits

  • Workspace folder tokens: Now supports ${workspaceFolder} and ${workspaceFolder:name}
  • Multi-workspace scenarios: Users can reference catalogs in different workspace folders by name
  • Backward compatibility: Existing configurations continue to work unchanged
  • Minimal changes: Only 13 lines modified, maintaining code stability

Example Usage

Users can now configure flexible catalog paths:

{
  "copilotCatalog.catalogDirectory": {
    "${workspaceFolder}/team-catalog": "Team Resources",
    "${workspaceFolder:shared-resources}/global-catalog": "Shared Assets",
    "local/resources": "Local Development"
  }
}

The ${workspaceFolder:shared-resources} token will correctly resolve to the workspace folder named "shared-resources", enabling better organization of catalogs across multiple workspace folders.

Fixes #12.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits September 16, 2025 05:22
Co-authored-by: joninafta <12600882+joninafta@users.noreply.github.com>
Co-authored-by: joninafta <12600882+joninafta@users.noreply.github.com>
Co-authored-by: joninafta <12600882+joninafta@users.noreply.github.com>
Copilot AI changed the title [WIP] Using relative paths in the catalog paths does not work Fix relative catalog path resolution with workspace folder tokens Sep 16, 2025
Copilot AI requested a review from joninafta September 16, 2025 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using relative paths in the catalog paths does not work

2 participants