Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Support mentioning filenames with spaces#3044

Merged
mrubens merged 2 commits into
mainfrom
jr/spaces-in-mentions
Apr 30, 2025
Merged

Support mentioning filenames with spaces#3044
mrubens merged 2 commits into
mainfrom
jr/spaces-in-mentions

Conversation

@jr

@jr jr commented Apr 29, 2025

Copy link
Copy Markdown
Contributor

Allows spaces to be escaped in mentions with \\. Does not attempt more comprehensive escape handling. (IMO a more structured representation or moving to something like @[something complex] is probably a better long term approach, but the scope of that seems daunting.

Adapted from 8955d45 / #2363.

Context

Addresses #2361

Screenshots

before

spaces-in-mentions-not-working.mov

after

spaces-in-mentions-escaped.mov

Important

Adds support for file path mentions with spaces by allowing spaces to be escaped with backslashes, updating regex patterns, and enhancing path handling functions.

  • Behavior:
    • Supports file path mentions with spaces by allowing spaces to be escaped with \\ in parseMentions() and openMention() in index.ts.
    • Updates mentionRegex in context-mentions.ts to match paths with escaped spaces.
    • insertMention() in context-mentions.ts now escapes spaces in file paths.
  • Tests:
    • Adds tests for escaped spaces in index.test.ts, context-mentions.test.ts, and path-mentions.test.ts.
    • Verifies correct handling of escaped spaces in mentions and context menu options.
  • Utilities:
    • Adds escapeSpaces() to path-mentions.ts to escape spaces in paths.
    • Updates convertToMentionPath() to handle paths with spaces.

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

Allows spaces to be escaped in mentions with \. Does not attempt more
comprehensive escape handling. (IMO a more structured representation or
moving to something like @[something complex] is probably a better long
term approach, but the scope of that seems problematic.

Adapted from 8955d45.

Co-authored-by: Matt Rubens <mrubens@users.noreply.github.com>
@changeset-bot

changeset-bot Bot commented Apr 29, 2025

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 07bb1f1

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

@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. Enhancement New feature or request labels Apr 29, 2025
* @returns A path with spaces escaped
*/
export function escapeSpaces(path: string): string {
return path.replace(/ /g, "\\ ")

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High

This does not escape backslash characters in the input.
// Check if there's any unescaped whitespace after the '@'
// We need to check for whitespace that isn't preceded by a backslash
// Using a negative lookbehind to ensure the space isn't escaped
const hasUnescapedSpace = /(?<!\\)\s/.test(textAfterAt)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The negative lookbehind regex /(?<!\)\s/ in shouldShowContextMenu might not be supported in older JS engines.

Suggested change
const hasUnescapedSpace = /(?<!\\)\s/.test(textAfterAt)
const hasUnescapedSpace = /(^|[^\\])\s/.test(textAfterAt)

@elianiva

Copy link
Copy Markdown
Contributor

IMO a more structured representation or moving to something like @[something complex] is probably a better long term approach, but the scope of that seems daunting

fwiw i started working on this in #2881, and yes the scope of it is quite big, haven't got the time to continue but will do it over the weekends
we can go with this solution for now, that PR will take quite some time before being actually usable

@cte cte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about the CodeQL error, but otherwise looks good, especially the test to non-test code ratio :)

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Apr 29, 2025

@mrubens mrubens left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@mrubens mrubens merged commit 34d7dcf into main Apr 30, 2025
13 of 14 checks passed
@mrubens mrubens deleted the jr/spaces-in-mentions branch April 30, 2025 02:27
@github-project-automation github-project-automation Bot moved this from New to Done in Roo Code Roadmap Apr 30, 2025
@samhvw8

samhvw8 commented Apr 30, 2025

Copy link
Copy Markdown
Contributor

@cte last time i change regex to string and using replaceAll codeql make that pass

'''
String.replaceAll(' ', '\ ')
'''

Something like this

SmartManoj pushed a commit to SmartManoj/Raa-Code that referenced this pull request May 6, 2025
* scroll

* menu

* changeset

* nit
SmartManoj pushed a commit to SmartManoj/Raa-Code that referenced this pull request May 6, 2025
* restoreTask protobus

* changeset

* changeset correction

* type safety change

* Fix Non-UTF-8 File Handling: Improve Encoding Detection to Prevent Garbled Text and Binary Misclassification (RooCodeInc#2347)

* Fix Non-UTF-8 File Handling: Improve Encoding Detection to Prevent Garbled Text and Binary Misclassification

* update package-lock.json

* update

* update

* fix

* fix

* fix

* ENG 526/Fix: Versioned Auto Approve settings (RooCodeInc#3014)

* added verisoning for autoApprove settings

* removed lines from source branch

* rebase

* changeset

* one small change

* activating extension with evals.env (RooCodeInc#3041)

Co-authored-by: Cline Evaluation <cline@example.com>

* ripping out test build flag (RooCodeInc#3043)

Co-authored-by: Cline Evaluation <cline@example.com>

* cleaning up evals.env logic in extension.ts (RooCodeInc#3045)

Co-authored-by: Cline Evaluation <cline@example.com>

* ENG-516 Slash commands (RooCodeInc#3044)

* scroll

* menu

* changeset

* nit

* What's yer path? (#3047)

* update extension imports to use aliasing

* changeset

* ENG-484 Enhance fixWithCline command execution by focusing chat input  (RooCodeInc#3028)

* Enhance fixWithCline command execution by focusing chat input and adding a delay before processing the fixWithCline command.

* feat: add OpenRouter base URL and balance display component

* feat: add OpenRouter base URL and balance display component

* feat: add OpenRouter base URL and balance display component

* new_task prompt (RooCodeInc#3049)

* prompt

* changeset

* words

* prettier

* Added metadata

---------

Co-authored-by: yt3trees <57471763+yt3trees@users.noreply.github.com>
Co-authored-by: pashpashpash <nik@cline.bot>
Co-authored-by: Cline Evaluation <cline@example.com>
Co-authored-by: Toshii <94262432+0xToshii@users.noreply.github.com>
Co-authored-by: Evan <58194240+celestial-vault@users.noreply.github.com>
Co-authored-by: nomaven <arafat.da.khan@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Enhancement New feature or request lgtm This PR has been approved by a maintainer size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants