From d9a9fd5d369099346fdcae621179704111365c9a Mon Sep 17 00:00:00 2001 From: Ashish Reddy Podduturi Date: Mon, 15 Sep 2025 13:25:59 -0700 Subject: [PATCH 1/2] fix(amazonq): fix for path parsing for windows for editable diff view --- packages/amazonq/src/lsp/chat/messages.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/amazonq/src/lsp/chat/messages.ts b/packages/amazonq/src/lsp/chat/messages.ts index 7460e6b9fb7..38f76963939 100644 --- a/packages/amazonq/src/lsp/chat/messages.ts +++ b/packages/amazonq/src/lsp/chat/messages.ts @@ -651,7 +651,16 @@ export function registerMessageListeners( ) languageClient.onNotification(openFileDiffNotificationType.method, async (params: OpenFileDiffParams) => { - const currentFileUri = vscode.Uri.parse(params.originalFileUri) + // Handle both file:// URIs and raw file paths, ensuring proper Windows path handling + let currentFileUri: vscode.Uri + try { + // Try parsing as URI first + currentFileUri = vscode.Uri.parse(params.originalFileUri, true) + } catch { + // If parsing fails, treat as file path and create URI + currentFileUri = vscode.Uri.file(params.originalFileUri) + } + const originalContent = params.originalFileContent ?? '' const fileName = path.basename(currentFileUri.fsPath) From 491239befc0d4c130370770708f1dc606f806489 Mon Sep 17 00:00:00 2001 From: Ashish Reddy Podduturi Date: Mon, 15 Sep 2025 17:51:53 -0700 Subject: [PATCH 2/2] fix: fix for windows --- packages/amazonq/src/lsp/chat/messages.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/amazonq/src/lsp/chat/messages.ts b/packages/amazonq/src/lsp/chat/messages.ts index 38f76963939..e607643d561 100644 --- a/packages/amazonq/src/lsp/chat/messages.ts +++ b/packages/amazonq/src/lsp/chat/messages.ts @@ -653,12 +653,14 @@ export function registerMessageListeners( languageClient.onNotification(openFileDiffNotificationType.method, async (params: OpenFileDiffParams) => { // Handle both file:// URIs and raw file paths, ensuring proper Windows path handling let currentFileUri: vscode.Uri - try { - // Try parsing as URI first - currentFileUri = vscode.Uri.parse(params.originalFileUri, true) - } catch { - // If parsing fails, treat as file path and create URI - currentFileUri = vscode.Uri.file(params.originalFileUri) + + // Check if it's already a proper file:// URI + if (params.originalFileUri.startsWith('file://')) { + currentFileUri = vscode.Uri.parse(params.originalFileUri) + } else { + // Decode URL-encoded characters and treat as file path + const decodedPath = decodeURIComponent(params.originalFileUri) + currentFileUri = vscode.Uri.file(decodedPath) } const originalContent = params.originalFileContent ?? ''