Skip to content

Commit f1c3ede

Browse files
authored
Fix: Improve drag-and-drop and SSH path handling (#2808)
* Fix: Correct path handling for dragged files on Windows * Fix: Improve drag-and-drop and SSH path handling
1 parent 29137fb commit f1c3ede

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

webview-ui/src/components/chat/ChatTextArea.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,10 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
614614
e.preventDefault()
615615
setIsDraggingOver(false)
616616

617-
const text = e.dataTransfer.getData("application/vnd.code.uri-list")
617+
const textFieldList = e.dataTransfer.getData("text")
618+
const textUriList = e.dataTransfer.getData("application/vnd.code.uri-list")
619+
// When textFieldList is empty, it may attempt to use textUriList obtained from drag-and-drop tabs; if not empty, it will use textFieldList.
620+
const text = textFieldList || textUriList
618621
if (text) {
619622
// Split text on newlines to handle multiple files
620623
const lines = text.split(/\r?\n/).filter((line) => line.trim() !== "")

webview-ui/src/utils/path-mentions.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,20 @@
1212
* @returns A mention-friendly path
1313
*/
1414
export function convertToMentionPath(path: string, cwd?: string): string {
15-
// Strip file:// protocol if present
16-
let pathWithoutProtocol = path.startsWith("file://") ? path.substring(7) : path
15+
// Strip file:// or vscode-remote:// protocol if present
16+
let pathWithoutProtocol = path
17+
18+
if (path.startsWith("file://")) {
19+
pathWithoutProtocol = path.substring(7)
20+
} else if (path.startsWith("vscode-remote://")) {
21+
const protocolStripped = path.substring("vscode-remote://".length)
22+
const firstSlashIndex = protocolStripped.indexOf("/")
23+
if (firstSlashIndex !== -1) {
24+
pathWithoutProtocol = protocolStripped.substring(firstSlashIndex + 1)
25+
} else {
26+
pathWithoutProtocol = ""
27+
}
28+
}
1729

1830
try {
1931
pathWithoutProtocol = decodeURIComponent(pathWithoutProtocol)

0 commit comments

Comments
 (0)