How to update request of SimpleDiffViewer?


Hi, I'm trying to make a plugin used to show difference of generated bytecode between different version of kotlin compilers. It should be somewhat looks like this:

My code for this simple ui is employing the `Kotlin UI DSL Version 2` and a `SimpleDiffViewer`, but I don't know how to:

send a new `SimpleDiffRequest` to my instance of SimpleDiffViewer once  a user of my plugin have choose different version of compilers, to update the diff viewer.




Your code repository seems to be private (404).


Sorry about the mistake, I forgot to change visibility, it's public now.


Note, that `SimpleDiffViewer` is not supposed to be used directly.
You can replace it with a `com.intellij.diff.DiffManager#createRequestPanel`.
Potentially, using `diffPanel.putContextHints(DiffUserDataKeysEx.FORCE_DIFF_TOOL, SimpleDiffTool.INSTANCE)` if "side-by-side" viewer needs to be enforced.

After that, you can update contents by passing a new `DiffRequest` to the `DiffRequestPanel.setRequest`.

As an alternative, you can create 2 `Document` (see `com.intellij.openapi.editor.EditorFactory#createDocument(java.lang.CharSequence)`) and use `DiffContentFactory.create(... Document ...)` to create contents.
After that, you can update `Document`s content as needed (just like any other document - under writeAction).
Note, that you might want to pass `com.intellij.diff.util.DiffUserDataKeys#FORCE_READ_ONLY` hint via diff panel context or request (or set `Document.setReadOnly` accordingly).

You can also try using

row {


It's exactly what I'm looking for, thanks for the great help!


Please sign in to leave a comment.