mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-07 08:26:51 +00:00
fix: prevent double @ prefix in drag-and-drop file paths
- Add early return in convertToMentionPath if path already starts with @ - Fixes issue where drag-and-drop paths like @/Logs/file.log would become @@/Logs/file.log - Add comprehensive tests for the new behavior - Resolves #5901
This commit is contained in:
parent
a6e16e80d9
commit
585f3ad0be
2 changed files with 25 additions and 0 deletions
|
|
@ -102,5 +102,25 @@ describe("Path Mentions Utilities", () => {
|
|||
const absPath = "/Users/test/project/src/file with spaces.ts"
|
||||
expect(convertToMentionPath(absPath, undefined)).toBe("/Users/test/project/src/file with spaces.ts")
|
||||
})
|
||||
|
||||
it("should return path as-is if it already starts with @", () => {
|
||||
const mentionPath = "@/src/file.ts"
|
||||
expect(convertToMentionPath(mentionPath, MOCK_CWD_POSIX)).toBe("@/src/file.ts")
|
||||
})
|
||||
|
||||
it("should return path as-is if it already starts with @ even with spaces", () => {
|
||||
const mentionPath = "@/src/file\\ with\\ spaces.ts"
|
||||
expect(convertToMentionPath(mentionPath, MOCK_CWD_POSIX)).toBe("@/src/file\\ with\\ spaces.ts")
|
||||
})
|
||||
|
||||
it("should return path as-is if it already starts with @ regardless of cwd", () => {
|
||||
const mentionPath = "@/Logs/SCC_Engine_2025-07-18_18-29-42_0.log"
|
||||
expect(convertToMentionPath(mentionPath, MOCK_CWD_POSIX)).toBe("@/Logs/SCC_Engine_2025-07-18_18-29-42_0.log")
|
||||
})
|
||||
|
||||
it("should return path as-is if it already starts with @ even when cwd is undefined", () => {
|
||||
const mentionPath = "@/some/path/file.txt"
|
||||
expect(convertToMentionPath(mentionPath, undefined)).toBe("@/some/path/file.txt")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -23,6 +23,11 @@ export function escapeSpaces(path: string): string {
|
|||
* @returns A mention-friendly path
|
||||
*/
|
||||
export function convertToMentionPath(path: string, cwd?: string): string {
|
||||
// If the path already starts with @, return it as-is to avoid double prefixing
|
||||
if (path.startsWith("@")) {
|
||||
return path
|
||||
}
|
||||
|
||||
// Strip file:// or vscode-remote:// protocol if present
|
||||
let pathWithoutProtocol = path
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue