FactoryInlayHintsCollector not created until I click in the editor Follow
I've created a plugin that displays text beside my Python source code. The display text scrolls in sync with the Python source code, but it gets out of sync in recent versions of PyCharm and IDEA when the inlay hints introduce gaps between lines of source code.
I'm trying to create a matching set of inlays in the display, so the two windows will scroll in sync again, but my collector only gets created when I click in the display window. Can I make the inlays appear as soon as I open the window? Is there a way to tell the InlayHintsPassFactory to create a highlighting pass?
I followed the guidance for creating inlay hints.
You can see my current code here.
Is there a better way to create a large text display in sync with Python source code? It often needs to scroll sideways to see more detail.
Please sign in to leave a comment.
Could you please provide a screenshot or video? I don't quite understand what the problem is/looks like, and the current implementation of DisplayInlayHintsCollector looks more like testing stage?
Thanks for checking it out, Yann. I've created a YouTube video demonstrating the problem and my partial fix. The code for my partial fix is here.
Thanks for the update. Did you try Tip 5) from here https://plugins.jetbrains.com/docs/intellij/inlay-hints.html#further-tips yet?
Seems like a good suggestion, Yann, but I don't see any change in behaviour. I posted my attempt here.
By the way, when I want to use new features like this, is there a way to gracefully degrade in older versions of PyCharm?
Sorry for delay.
Try to avoid using InlayHintsProvider and use directly lower level API: InlayModel. Check the height of the block inlays extracted from the document and make com.intellij.openapi.editor.EditorCustomElementRenderer which does nothing, but has given height. Add inlay listener via com.intellij.openapi.editor.InlayModel#addListener - this way changes in inlay will be immediately picked up.
About degrading, this usually works best by releasing two distinct plugin versions, each targeting a specific version range. See also https://plugins.jetbrains.com/docs/intellij/verifying-plugin-compatibility.html
That did it, thanks for all the help!