Skip to content

Conversation

sjf
Copy link
Contributor

@sjf sjf commented Aug 2, 2025

This change allows users to reference files with spaces in their names, which was previously impossible due to the space-delimited mention syntax.
File names with spaces can be @ mentioned by quoting the file name, e.g. @"/path with spaces/file.txt".

Fixes #5304

  • Update mention regex in src/shared/context-mentions.ts to accept quoted file paths

    • Add support for quoted file paths that can contain spaces.
    • Allow multiple trailing punctuation chars; previously only a single limited punctuation characters were allowed.
    • Maintain support for unquoted paths, URLs, git hashes, and special keywords
  • Update src/core/mentions/index.ts to handle quoted file names in mention parsing

    • Process quoted file paths by removing quotes when accessing the file system
    • Preserve existing functionality for all other mention types
  • Update webview-ui/src/utils/context-mentions.ts to auto-quote file names with spaces

    • insertMention() and insertMentionDirectly() now wrap file paths containing spaces in quotes
    • Non-file mentions (URLs, keywords) remain unquoted
  • Add comprehensive unit tests:

    • New test file src/core/mentions/__tests__/index.test.ts covering all mention types
    • New test file webview-ui/src/utils/__tests__/context-mentions.test.ts for webview mention insertion
    • Expanded src/shared/__tests__/context-mentions.test.ts to cover quoted paths and edge cases
Screen.Recording.2025-08-02.at.21.50.15.mov

Important

Support for file mentions with spaces by quoting paths, updating regex, parsing logic, and UI components, with comprehensive tests added.

  • Behavior:
    • Support for file mentions with spaces by quoting file paths, e.g., @"/path with spaces/file.txt".
    • Updated mention regex in context-mentions.ts to handle quoted file paths and allow multiple trailing punctuation characters.
    • Updated parseMentions() in index.ts to process quoted file paths by removing quotes.
    • Updated insertMention() and insertMentionDirectly() in context-mentions.ts to auto-quote file paths with spaces.
  • Tests:
    • Added index.test.ts for mention parsing covering all mention types.
    • Added context-mentions.test.ts for webview mention insertion.
    • Expanded context-mentions.test.ts to cover quoted paths and edge cases.

This description was created by Ellipsis for 3cbf5ba. You can customize this summary. It will automatically update as commits are pushed.

Copy link

changeset-bot bot commented Aug 2, 2025

⚠️ No Changeset found

Latest commit: 3cbf5ba

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@sjf sjf force-pushed the sjf-a2-alsfjdk branch from 4b65850 to e472471 Compare August 2, 2025 21:07
@sjf sjf changed the title feat: support file mentions with spaces using quoted syntax feat: support mentions for filenames with spaces Aug 2, 2025
@sjf sjf force-pushed the sjf-a2-alsfjdk branch from e472471 to bb4e2da Compare August 2, 2025 21:09
Copy link
Contributor

github-actions bot commented Aug 2, 2025

Coverage Report

Extension Coverage

Base branch: 47%

PR branch: 48%

✅ Coverage increased or remained the same

Webview Coverage

Base branch: 17%

PR branch: 17%

✅ Coverage increased or remained the same

Overall Assessment

Test coverage has been maintained or improved

Last updated: 2025-08-04T18:10:01.839005

@sjf sjf changed the title feat: support mentions for filenames with spaces Support mentions for filenames with spaces Aug 2, 2025
@lcswillems
Copy link

So happy that a PR to fix this issue is being made!! That's by far the biggest painpoint I was encountering with Cline. Was seriously thinking of renaming all my files because of this... Hopefully I won't need it

@sjf sjf force-pushed the sjf-a2-alsfjdk branch from bb4e2da to d79bee1 Compare August 4, 2025 00:04
@canvrno
Copy link
Contributor

canvrno commented Aug 4, 2025

Tested with filenames that have spaces & multiple spaces. This is working as expected and tests are passing. One small variable nitpick.

This change allows users to reference files with spaces in their names, which was previously impossible due to the space-delimited mention syntax.
File names with spaces can be @ mentioned by quoting the file name, e.g. @"/path with spaces/file.txt".

- Update mention regex in `src/shared/context-mentions.ts` to accept quoted file paths
  - Add support for quoted file paths that can contain spaces.
  - Allow multiple trailing punctuation chars; previously only a single limited punctuation characters were allowed.
  - Maintain support for unquoted paths, URLs, git hashes, and special keywords

- Update `src/core/mentions/index.ts` to handle quoted file names in mention parsing
  - Process quoted file paths by removing quotes when accessing the file system
  - Preserve existing functionality for all other mention types

- Update `webview-ui/src/utils/context-mentions.ts` to auto-quote file names with spaces
  - `insertMention()` and `insertMentionDirectly()` now wrap file paths containing spaces in quotes
  - Non-file mentions (URLs, keywords) remain unquoted

- Add comprehensive unit tests:
  - New test file `src/core/mentions/__tests__/index.test.ts` covering all mention types
  - New test file `webview-ui/src/utils/__tests__/context-mentions.test.ts` for webview mention insertion
  - Expanded `src/shared/__tests__/context-mentions.test.ts` to cover quoted paths and edge cases
@sjf sjf force-pushed the sjf-a2-alsfjdk branch from d79bee1 to 536f38b Compare August 4, 2025 17:55
@sjf sjf merged commit 0d933e8 into main Aug 4, 2025
13 checks passed
@sjf sjf deleted the sjf-a2-alsfjdk branch August 14, 2025 12:53
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.

Mentions don't work with filenames containing a space
4 participants