Highlighting of read-only blocks

I want to setup for document some read-only blocks and  higlight them to see where are they.
Currently I use com.intellij.openapi.editor.Document#createGuardedBlock to create read-only blocks and com.intellij.openapi.editor.markup.MarkupModel#addRangeHighlighter to highlight them.
Maybe someone has an idea how do this better?
I'm asking because I have problem with highlighting updates - when I reload externally modified document I need to update position of read-only blocks and highlighting of them. So I remove them and create new ones. At first refresh of editor I see new position of highlighting, but one second later it comes back to previous position (before document reload) - read-only block are up to date, but highlighting looks invalid. It's back to valid position on second document reload or on re-focus of document editor window.

1 comment

I believe, it's done by default if it's set up in color scheme. Check 'Readonly fragment background' in color scheme configuration. It's set for default scheme, but not set for Darcula currently.


Please sign in to leave a comment.