Skip to content

Commit ee0a8c4

Browse files
authored
Merge pull request aws#6883 from ctlai95/open-file
fix(chat): file links open in other apps
2 parents b910472 + 9c439f6 commit ee0a8c4

File tree

1 file changed

+14
-1
lines changed
  • packages/core/src/codewhispererChat/controllers/chat

1 file changed

+14
-1
lines changed

packages/core/src/codewhispererChat/controllers/chat/controller.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,20 @@ export class ChatController {
305305
}
306306

307307
private processResponseBodyLinkClick(click: ResponseBodyLinkClickMessage) {
308-
this.openLinkInExternalBrowser(click)
308+
const uri = vscode.Uri.parse(click.link)
309+
if (uri.scheme === 'file') {
310+
void this.openFile(uri.fsPath)
311+
} else {
312+
this.openLinkInExternalBrowser(click)
313+
}
314+
}
315+
316+
private async openFile(absolutePath: string) {
317+
const fileExists = await fs.existsFile(absolutePath)
318+
if (fileExists) {
319+
const document = await vscode.workspace.openTextDocument(absolutePath)
320+
await vscode.window.showTextDocument(document)
321+
}
309322
}
310323

311324
private processSourceLinkClick(click: SourceLinkClickMessage) {

0 commit comments

Comments
 (0)