LSP icon indicating copy to clipboard operation
LSP copied to clipboard

inlay hints should disappear if the region they're attached to is removed

Open rwols opened this issue 4 years ago • 6 comments

It's annoying that the hints stay visible for a short while when a region is removed. Can anything be done about this?

https://user-images.githubusercontent.com/2431823/122651017-681b7080-d136-11eb-8a95-e81e35ce209f.mov

rwols avatar Jun 19 '21 17:06 rwols

It's the same with regions. If you delete the text with a region highlight then the region will collapse into an empty region and shift but still will be visible until we erase it.

In many cases it's expected that it behaves like that (when adding text in front of it, for example) so it's not a clear-cut bug in ST at least.

I think on our side we could do something about it but it would probably involve handling regions from the sync on_modified or on_text_changed which would likely have performance impact.

rchl avatar Jun 19 '21 17:06 rchl

I fear it's because the phantom region is declared to be of zero length. This makes ST try to "keep it around" I think, because removing a line with a zero-length phantom, you can view that as just "moving" the zero-length region.

Just for illustration here I've modified the phantoms to not use zero-length regions, but the actual regions reported by the language server. I've also made them be drawn below. This now has the expected behavior of immediately removing the phantoms associated to the region:

https://user-images.githubusercontent.com/2431823/122652159-a5cfc780-d13d-11eb-9f50-be6035e92140.mov

rwols avatar Jun 19 '21 18:06 rwols

Putting it below is not particularly good looking though :)

https://user-images.githubusercontent.com/2431823/122652434-204d1700-d13f-11eb-834f-7ca20e22fd5d.mov

rwols avatar Jun 19 '21 18:06 rwols

OK, I haven't checked how Phantoms work. Was talking in the context of regions like here:

https://user-images.githubusercontent.com/153197/122652688-4c1ccc80-d140-11eb-9b24-f8e4419f75b5.mov

rchl avatar Jun 19 '21 18:06 rchl

I guess things from add_regions behaves differently in that respect than from PhantomSet.

I'm afraid we're going to need a sublime.LAYOUT_INLINE_ALIGN_LEFT and sublime.LAYOUT_INLINE_ALIGN_RIGHT flag to communicate to ST that the inline phantom is supposed to align either left or right of the already existing region filled with text.

bla bla bla
    ^^^ existing text, attaching an
        inline phantom could render
        to the left or to the right of it

rwols avatar Jun 19 '21 21:06 rwols

(Transferred to LSP project as it's a more generic issue. And the inlay hints implementation is now in LSP.)

rchl avatar Aug 31 '22 18:08 rchl