Highlighting a line: ViewPlugin vs StateField

Hi,

I have an editor with a gutter that I use to set breakpoints. When the code hits a breakpoint, I want to highlight the corresponding line. I see two ways of doing it, either with a ViewPlugin, of with a StateField. In both cases, I need to create a StateEffect that will be dispatched so that the update method is called. My question is which method is the best and why?

Besides, I need to be able to type code in the editor when the hilghlight is on and have it updated accordingly. This means that if I use a ViewPlugin, I need to store the position of the highlight somewhere. Is it ok to store such a value in the ViewPlugin?

Thanks

Generally, if something is state that should be preserved (rather than derived state that can be reconstructed from other state), putting it in a state field is preferable.

Ok got it. Thank you rvery much for your quick answer.