Skip to content

Commit

Permalink
fix(terminal): handle terminal text retrieval with reflection
Browse files Browse the repository at this point in the history
Use reflection to safely retrieve text from terminalWidget and handle potential exceptions. Notify user if the operation fails.
  • Loading branch information
phodal committed Jan 24, 2025
1 parent 065c149 commit b8cc0e6
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,13 @@ class TerminalLangSketchProvider : LanguageSketchProvider {
val sendButton = JButton("Send to Sketch").apply {
addMouseListener(object : MouseAdapter() {
override fun mouseClicked(e: MouseEvent?) {
val output = terminalWidget!!.text
sendToSketch(project, output)
try {
val output = terminalWidget!!::class.java.getMethod("getText")
.invoke(terminalWidget) as String
sendToSketch(project, output)
} catch (e: Exception) {
AutoDevNotifications.notify(project, "Failed to send to Sketch")
}
}
})
}
Expand Down

0 comments on commit b8cc0e6

Please sign in to comment.