Support mentioning filenames with spaces#3044
Conversation
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>
|
| * @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
| // 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) |
There was a problem hiding this comment.
The negative lookbehind regex /(?<!\)\s/ in shouldShowContextMenu might not be supported in older JS engines.
| const hasUnescapedSpace = /(?<!\\)\s/.test(textAfterAt) | |
| const hasUnescapedSpace = /(^|[^\\])\s/.test(textAfterAt) |
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 |
cte
left a comment
There was a problem hiding this comment.
Not sure about the CodeQL error, but otherwise looks good, especially the test to non-test code ratio :)
|
@cte last time i change regex to string and using replaceAll codeql make that pass ''' Something like this |
* scroll * menu * changeset * nit
* 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>
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.
\\inparseMentions()andopenMention()inindex.ts.mentionRegexincontext-mentions.tsto match paths with escaped spaces.insertMention()incontext-mentions.tsnow escapes spaces in file paths.index.test.ts,context-mentions.test.ts, andpath-mentions.test.ts.escapeSpaces()topath-mentions.tsto escape spaces in paths.convertToMentionPath()to handle paths with spaces.This description was created by
for 07bb1f1. You can customize this summary. It will automatically update as commits are pushed.