Scrollbar decorator service
Have you checked for existing feature requests?
- [x] Completed
Summary
In pulsar-find-references, I had a use case for marking the scrollbar gutter with notches to indicate the positions of other references to the token under the cursor. I used minimap as a reference and ended up building a custom element that draws a canvas under the vertical scrollbar of a TextEditor component, then makes the scrollbar slightly transparent when there are markers to be shown.
Other packages have done the same thing for find-and-replace results.
We should make the canonical implementation of this scrollbar gutter and let other packages use it as a service.
What benefits does this feature provide?
The ability to mark various positions on the scrollbar gutter would be useful for a number of applications:
-
find-and-replaceresults - LSP “Find References” requests
- bookmarks
-
linterannotations
and many more.
Any alternatives?
The status quo: either
- every package does its own thing and creates its own element to serve the same purpose (and they get in each other's way), or
- most packages don't bother to do this even though it would be convenient.
Other examples:
Yes — VS Code once again. Both find-and-replace results and find-references requests can use the scrollbar gutter at the same time. Each one uses a different color (not immediately sure how they decide or whether it's configurable). Each annotation is a square in the middle of the gutter.
Cursor positions are also drawn in the gutter, though the mark is different — a thin, wide line rather than a square.
I am the author of the scroll-map package. I created it to meet my personal needs, because the minimap package is too fancy for me. I am an inexperienced programmer and the package may be a little bit poor and need improvements. At the moment it supports three layers of markers: cursor location, find-and-replace result location, navigation-panel header location. There is also a service available to support new layers, but so far I have not had the need to document it.... If you want I can collaborate in improving this package and/or transferring it to pulsar's built-in resources, if that makes sense at all. It may be optimal to write another package from scratch. Best regards.
@asiloisad, before I researched this issue I hadn't noticed the scroll-map package, so it was a pleasant surprise to find. You're prolific enough that I should've guessed that you had written something like this!
I suspect we will end up writing our own package, but I will certainly look at scroll-map for inspiration at the very least.