I have some code that goes to a new location in a thread and am trying to update the debug thread view to reflect that. It looks like this:
context.initExecutionStacks(threadProxy)
val xDebugSession = session.xDebugSession as XDebugSessionImpl
val stack = context.activeExecutionStack as JavaExecutionStack
ApplicationManager.getApplication().invokeLater {
xDebugSession.setCurrentStackFrame(stack, stack.topFrame!!)
xDebugSession.positionReached(context, true)
and this works most of the time but sometimes it doesn’t update and displays the wrong thread. I should note that this is implementing “step across” from one microservices session to another (see https://docs.undo.io/java/IntelliJIdePlugin.html#stepacross) so it changes focus to the other session tab and then after a session resume/session pause attempts to update the view to reflect the new state. Note also that this is all kind of going behind IntelliJ’s back as we are trying to trick IntelliJ into thinking it is effectively the same as if you had done a normal resume and then hit a breakpoint.
Like I say most of the time it works but I can’t figure out why it doesn’t sometimes. I have tried everything I can think of including putting delays in at various places thinking it must be a timing issue, getting hold of the XDebuggerEmbeddedComboBox and doing revalidate/repaint but nothing seems to work. Interestingly sometimes if I switch to the other session tab and then back again it updates correctly! (But not always). I can manually set the correct thread via the popup and see a tick next to my desired thread so it seems to have half worked. (I even tried updating the combox box using a PopupMenuListener and showPopup but get same issue)