Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
@@ -0,0 +1,4 @@
{
"type" : "feature",
"description" : "/review: Code fix automatically scrolls into view after generation."
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import javax.swing.JEditorPane
import javax.swing.JLabel
import javax.swing.JPanel
import javax.swing.ScrollPaneConstants
import javax.swing.SwingUtilities
import javax.swing.event.HyperlinkEvent
import javax.swing.text.html.HTMLEditorKit

Expand All @@ -71,6 +72,9 @@ internal class CodeWhispererCodeScanIssueDetailsPanel(
)
editorPane.revalidate()
editorPane.repaint()
SwingUtilities.invokeLater {
Copy link
Contributor

Choose a reason for hiding this comment

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

runInEdt or ApplicationManager.getApplication().invokeLater. Please read the documentation block for the latter for an explaination

also note that the block inside the closure is run async if that is not that expectation

editorPane.scrollToReference("fixLoadingSection")
}

val codeFixResponse: AmazonQCodeFixSession.CodeFixResponse = amazonQCodeFixSession.runCodeFixWorkflow(issue)
if (codeFixResponse.failureResponse != null) {
Expand All @@ -81,6 +85,9 @@ internal class CodeWhispererCodeScanIssueDetailsPanel(
)
revalidate()
repaint()
SwingUtilities.invokeLater {
scrollToReference("fixFailureSection")
}
}
} else {
val isReferenceAllowed = CodeWhispererSettings.getInstance().isIncludeCodeWithReference()
Expand Down Expand Up @@ -115,6 +122,9 @@ internal class CodeWhispererCodeScanIssueDetailsPanel(
)
revalidate()
repaint()
SwingUtilities.invokeLater {
scrollToReference("codeFixActions")
}
}

buttonPane.apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ fun getCodeScanIssueDetailsHtml(
}

val fixLoadingSection = """
<a name="fixLoadingSection"></a>
<div align="center" bgcolor="#2b2b2b" style="margin: 20px;">
<font size="7" color="#ffffff" face="Arial">
&nbsp;&nbsp;&nbsp;&nbsp;...&nbsp;&nbsp;&nbsp;&nbsp;
Expand All @@ -145,6 +146,7 @@ fun getCodeScanIssueDetailsHtml(
""".trimIndent()

val fixFailureSection = """
<a name="fixFailureSection"></a>
<div align="center" bgcolor="#2b2b2b" style="margin: 20px;">
<font size="4" color="#e6e6e6" face="Arial">
<br>Amazon Q failed to generate fix. Please try again<br>
Expand Down Expand Up @@ -192,6 +194,7 @@ private fun createSuggestedFixSection(issue: CodeWhispererCodeScanIssue, suggest
|${it.code.trim()}
|```
|</div>
|<a name="codeFixActions"></a>
|<div>
| <a href="amazonq://issue/openDiff-${issue.findingId}">
| <font size="+1"><i>&#x2194;</i></font> <b>Open Diff</b>
Expand Down
Loading