Skip to content

fix(amazonq): Fix prompt file not opening in windows #5750

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

Merged
merged 5 commits into from
May 22, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ import software.aws.toolkits.jetbrains.utils.getCleanedContent
import software.aws.toolkits.jetbrains.utils.notify
import software.aws.toolkits.resources.message
import java.io.File
import java.net.URLDecoder
import java.nio.charset.StandardCharsets
import java.nio.file.Files
import java.nio.file.Paths
import java.util.UUID
Expand Down Expand Up @@ -143,18 +145,20 @@ class AmazonQLanguageClientImpl(private val project: Project) : AmazonQLanguageC

override fun showDocument(params: ShowDocumentParams): CompletableFuture<ShowDocumentResult> {
try {

if (params.uri.isNullOrEmpty()) {
return CompletableFuture.completedFuture(ShowDocumentResult(false))
}

val fileToOpen = URLDecoder.decode(params.uri, StandardCharsets.UTF_8.name())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please include inline comment why

if (params.external == true) {
BrowserUtil.open(params.uri)
BrowserUtil.open(fileToOpen)
return CompletableFuture.completedFuture(ShowDocumentResult(true))
}

ApplicationManager.getApplication().invokeLater {
try {
val virtualFile = VirtualFileManager.getInstance().findFileByUrl(params.uri)

val virtualFile = VirtualFileManager.getInstance().findFileByUrl(fileToOpen)
?: throw IllegalArgumentException("Cannot find file: ${params.uri}")

FileEditorManager.getInstance(project).openFile(virtualFile, true)
Expand Down
Loading