Streaming content to a custom `DiffRequestPanel`

Hey @ilia.shulgin , thanks a lot for this suggestion!
This gets me closer, but it’s not behaving as I’d expect.
Would you mind addressing the following remarks?

Remarks

Mainly, having to go through runWriteCommandAction is rather annoying because it delays the content updates. Is there a way to avoid that?

Among other things, despite content2.document being updated in a timely fashion, the diff view itself takes a while before its content is updated.

I tried to find what I should call within the WriteAction, but to no avail. :frowning:

At first, I attempted to call this within the WriteAction:

  private fun onUpdatedUi() {
    myDiffRequestPanel.component.invalidate()
    myDiffRequestPanel.component.revalidate()
    myDiffRequestPanel.component.repaint()
  }

Then, I tried using myProcessor#updateRequest within the WriteAction but:

  • When using force = false parameter, it doesn’t solve the issue
  • When using force = true parameter, it does update the UI more often, but it seems very resource intensive and can eventually freeze the UI

I also tried calling myProcessor.setRequest().

Finally, I tried going through only runInEdt { ApplicationManager.getApplication().runWriteAction { ... } } (i.e. without calling WriteCommandAction#runWriteCommandAction since it’s unclear why that’s necessary anyways)… but that also didn’t resolve the issue.

Would you mind trying out your solution within an embedded Inlay Component (instead of using DiffManager.getInstance().showDiff(project, request)), with a much lower Thread#sleep value? This should help you see the performance issues.
Beyond the selection bug, there is also this issue that comes up when working with this within an Inlay Components.

More quirks

Moreover, for some reason, the very first time I try to select code in the displayed DiffRequestPanel, there is close to a 2-seconds delay before the selection actually happens.
That is the case even once there are no more updates coming in.