Skip to content

Commit

Permalink
fix: illegal component state exception
Browse files Browse the repository at this point in the history
  • Loading branch information
carlrobertoh committed Dec 27, 2024
1 parent a596fa9 commit 091fda4
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import java.awt.event.KeyEvent
import javax.swing.Box
import javax.swing.JComponent
import javax.swing.JPanel
import javax.swing.SwingUtilities

class CodeSuggestionDiffViewer(
request: DiffRequest,
Expand Down Expand Up @@ -294,6 +295,12 @@ fun UnifiedDiffChange.getChangedLinesCount(): Int {

fun getAdjustedPopupLocation(popup: JBPopup, editor: Editor, changeOffset: Int): Point {
val pointInEditor = editor.offsetToXY(changeOffset)
if (!editor.component.isShowing) {
val point = Point(pointInEditor)
SwingUtilities.convertPointToScreen(point, editor.component)
return point
}

val visibleArea = editor.scrollingModel.visibleArea
val editorLocationOnScreen = editor.component.locationOnScreen
val isOffsetVisible = visibleArea.contains(pointInEditor)
Expand Down

0 comments on commit 091fda4

Please sign in to comment.