8000 Incorrect escaping of spaces in file paths causes mention highlighting and file access failures · Issue #2564 · RooVetGit/Roo-Code · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Incorrect escaping of spaces in file paths causes mention highlighting and file access failures #2564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Yikai-Liao opened this issue Apr 13, 2025 · 1 comment
Labels
bug Something isn't working in progress Actively being worked on

Comments

@Yikai-Liao
Copy link

App Version

3.11.14

API Provider

OpenRouter

Model Used

Claude 3.7 Sonnet

Actual vs. Expected Behavior

Actual Behavior:

  • When a file path contains spaces or special characters, the @ mention highlighting doesn't work correctly
  • The system fails to properly read or access files with spaces in their paths when referenced using the @ mention syntax
  • Multiple backslashes are added inconsistently, causing path resolution issues
  • In some cases, file paths with existing escaped spaces get double-escaped incorrectly

Expected Behavior:

  • File paths with spaces should be properly escaped with backslashes
  • The @ mention highlighting should work correctly for all file paths regardless of spaces or special characters
  • Files with spaces in their paths should be correctly accessed when referenced using the @ mention syntax
  • Already escaped spaces should not be double-escaped in an incorrect manner

Detailed Steps to Reproduce

  1. Create a folder and a file with spaces in their names (e.g., folder with spaces/file with spaces.txt)
  2. In the editor, type @ to trigger the mention functionality
  3. Select the file with spaces from the file list
  4. Observe that the file path is incorrectly escaped in the editor
  5. Try to access the file by clicking on the mention link
  6. Observe that the file cannot be opened or is opened incorrectly

Code to demonstrate the issue:

// Create a path with spaces
const path = "/path/to/folder with spaces/file with spaces.txt";

// Convert to mention path
const mentionPath = convertToMentionPath(path, "/path/to");

// Expected: "@/folder\ with\ spaces/file\ with\ spaces.txt"
// Actual: Incorrect escaping that varies depending on context
console.log(mentionPath);

// When using insertMention, the spaces are handled inconsistently
const result = insertMention("Check this file: ", cursorPosition, mentionPath.substring(1));

Relevant API Request Output

Additional Context

The issue occurs due to multi-level escaping problems in two key utility functions:

  1. convertToMentionPath in path-mentions.ts - Fails to properly handle paths with spaces and existing escaped spaces
  2. insertMention in context-mentions.ts - Doesn't consistently handle the escaped paths

This issue affects both Windows and Unix-style paths. The problem is particularly severe when files already contain escaped spaces, as the escaping logic doesn't account for this case.

The bug impacts users trying to reference files with spaces in their paths, which is a common scenario especially in project names, documentation folders, and descriptive file naming schemes.

Debug info:

  • Operating System: Affects all platforms (Windows, macOS, Linux)
  • Plugin version: [Your version number]
  • Reproducible with: Any file paths containing spaces
@Yikai-Liao Yikai-Liao added the bug Something isn't working label Apr 13, 2025
@hannesrudolph hannesrudolph linked a pull request Apr 15, 2025 that will close this issue
@hannesrudolph hannesrudolph moved this from New to Issue [In Progress] in Roo Code Roadmap Apr 15, 2025
@hannesrudolph hannesrudolph added the in progress Actively being worked on label Apr 17, 2025
@mrubens
Copy link
Collaborator
mrubens commented Apr 30, 2025

Hi, this should be fixed in the latest release - can you try again?

@github-project-automation github-project-automation bot moved this from Issue [In Progress] to Done in Roo Code Roadmap May 2, 2025
SmartManoj pushed a commit to SmartManoj/Roo-Code that referenced this issue May 6, 2025
…ename Cline to Task (RooVetGit#2564)

* refactor: Replace ClineProvider with Controller for improved architecture

- Replaced instances of ClineProvider with Controller in extension.ts and related files to enhance code organization and maintainability.
- Introduced a new Controller class to manage interactions previously handled by ClineProvider, streamlining the extension's functionality.
- Updated command registrations and message handling to utilize the new Controller structure, ensuring consistent behavior across the extension.
- Removed the ClineProvider class and its associated methods, consolidating functionality within the Controller class.
- Added new state management and task handling capabilities within the Controller to support the updated architecture.

* clean up

* refactor: Update Task class to use Controller reference

- Replaced all instances of ClineProvider with Controller in the Task class to align with the recent architectural changes.
- Updated references for context management, task history, and message handling to utilize the new Controller structure.
- Ensured consistent behavior across the Task class by adapting to the Controller's methods and properties.

* refactor: Simplify WebviewProvider listeners structure

* Fixes

* Make controller a dependency of webview

* refactor: Improve message listener in WebviewProvider

- Updated the setWebviewMessageListener method to use an arrow function for the message handler, preserving the 'this' context of the controller.
- Added detailed comments explaining the importance of maintaining the correct 'this' context when passing methods as callbacks in JavaScript/TypeScript.

* Add doc

* Add to chat for visible webview

* Fixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working in progress Actively being worked on
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants
0