Skip to content

fix: nameFormat not respected in multi-root workspace - #247

Merged
douglasgomes98 merged 5 commits into
mainfrom
246-name-pattern-not-working-in-a-multi-root-workspace
Apr 20, 2026
Merged

douglasgomes98 merged 5 commits into
mainfrom
246-name-pattern-not-working-in-a-multi-root-workspace

Conversation

@douglasgomes98

Copy link
Copy Markdown
Owner

Summary

  • Fixes nameFormat (and other template settings) being ignored when using a multi-root workspace
  • Root cause: readConfig was receiving the workspace folder root URI, but vscode.workspace.getConfiguration requires a resource URI (the actual file/folder the user clicked) to resolve per-folder settings correctly
  • Fix: pass clickedUri instead of workspaceFolderUri to readConfig in both createComponent and updateComponent

Test plan

  • Added multi-root workspace test suite to createComponent and updateComponent
  • Verifies that clicking inside folder A uses folder A's config (e.g. kebab-case)
  • Verifies that clicking inside folder B uses folder B's config independently
  • Verifies that getConfiguration is called with clickedUri, not the workspace root
  • All 58 tests pass, linter clean

Closes #246

🤖 Generated with Claude Code

douglasgomes98 and others added 2 commits April 20, 2026 13:45
…onfig resolution

vscode.workspace.getConfiguration requires a resource URI (not the workspace folder
root) to resolve per-folder settings. Passing the workspace root caused nameFormat
and other template settings to be ignored in multi-root workspaces.

Adds multi-root workspace tests to createComponent and updateComponent verifying
that each folder's config is resolved independently based on the clicked path.

Closes #246

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…plates folder

The manual startsWith check in findWorkspaceFolderUri had a path-prefix collision
bug: a click inside /packages/application would incorrectly match /packages/app,
causing templates to be looked up in the wrong workspace folder.

Replace the custom implementation with vscode.workspace.getWorkspaceFolder(uri)
which handles path boundary matching correctly. Add getWorkspaceFolder to the
vscode mock as a plain function (immune to jest.resetAllMocks) that reads
workspaceFolders dynamically with proper path separator and specificity sorting.

Adds regression tests for the path-prefix collision scenario.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@douglasgomes98

Copy link
Copy Markdown
Owner Author

Update: Found and fixed a second related bug.

The findWorkspaceFolderUri helper used startsWith(f.path) without a path separator, causing a false match when one workspace folder name is a prefix of another (e.g. clicking inside /packages/application would incorrectly resolve to the /packages/app workspace folder, looking for templates in the wrong place).

Fix: replaced the custom path-matching logic with vscode.workspace.getWorkspaceFolder(uri) — the VS Code API built for this purpose, which handles path boundaries correctly. Also added getWorkspaceFolder to the vscode mock and regression tests for the path-prefix collision scenario.

douglasgomes98 and others added 3 commits April 20, 2026 14:22
Without scope: "resource", VS Code treats settings as window-scoped by default,
which means .vscode/settings.json inside each workspace folder is silently ignored.
Only .code-workspace file overrides were applied, so per-project templatesFolderPath
and templateSettings were never picked up in multi-root workspaces.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Deleted .gitkeep files from components and services directories, along with their associated template files for component and service generation. This cleanup helps streamline the project structure by removing obsolete templates.
- src/helpers/fs/ and its tests: all fs wrappers were unused in production
- src/helpers/vscode/getWorkspaceFolders.ts and its test: removed from commands
  in the multi-root workspace refactor
- src/helpers/index.ts: barrel file never imported anywhere
- Remove getWorkspaceFolders/WorkspaceFolder exports from vscode/index.ts

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@douglasgomes98
douglasgomes98 merged commit fb4ca75 into main Apr 20, 2026
3 checks passed
@douglasgomes98
douglasgomes98 deleted the 246-name-pattern-not-working-in-a-multi-root-workspace branch April 20, 2026 17:48
github-actions Bot pushed a commit that referenced this pull request Apr 20, 2026
## [2.0.1](v2.0.0...v2.0.1) (2026-04-20)

### Bug Fixes

* nameFormat not respected in multi-root workspace ([#247](#247)) ([fb4ca75](fb4ca75)), closes [#246](#246)
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 2.0.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Name pattern not working in a multi-root workspace

1 participant