editor: Add minimap
Overview
This PR adds the minimap feature to the Zed editor, closely following the design from Visual Studio Code. When configured, a second instance of the editor will appear to the left of the scrollbar. This instance is not interactive and it has a slimmed down set of annotations, but it is otherwise just a zoomed-out version of the main editor instance. A thumb shows the line boundaries of the main viewport, as well as the progress through the document. Clicking on a section of code in the minimap will jump the editor to that code. Dragging the thumb will act like the scrollbar, moving sequentially through the document.
New settings
This adds a minimap section to the editor settings with the following keys:
show
When to show the minimap in the editor. This setting can take three values:
- Show the minimap if the editor's scrollbar is visible:
"auto" - Always show the minimap:
"always" - Never show the minimap:
"never"(default)
thumb
When to show the minimap thumb. This setting can take two values:
- Show the minimap thumb if the mouse is over the minimap:
"hover" - Always show the minimap thumb:
"always"(default)
width
The width of the minimap in pixels.
Default: 100
font_size
The font size of the minimap in pixels.
Default: 2
Providing feedback
In order to keep the PR focused on development updates, please use the discussion thread for feature suggestions and usability feedback: #26894
Features left to add
- [x] fix scrolling performance
- [x] user settings for enable/disable, width, text size, etc.
- [x] show overview of visible lines in minimap
- [x] clicking on minimap should navigate to the corresponding section of code
- ~[ ] more prominent highlighting in the minimap editor~
- ~[ ] override scrollbar auto setting to always when minimap is set to always show~
Release Notes:
- Added minimap for high-level overview and quick navigation of editor contents.
We require contributors to sign our Contributor License Agreement, and we don't have @esimkowitz on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.
@cla-bot check
The cla-bot has been summoned, and re-checked this pull request!
I think the performance implication with scrolling that I was noticing was actually just a standard degradation of the debug environment vs the release environment - I don't notice it when I run a release build so no concern there. I do notice some jumping, though, I think it may be related to the issue you noted where the minimap detaches. I'll take a look at this and the other notes you've made, thank you for such a detailed review!
which has very simplified rendering
Thinking some more on this, what if we swap every character for a block that is the full width of the em?
I also like the idea of the bracketed highlighting, will look into this. I think this can work well
Thankfully the bouncing issue was simple to fix, I was using window.with_absolute_element_offset when I should have used window.with_element_offset
Okay big update, I have the display logic working I think, including the slider thumb. It isn't interactive yet, but if folks could try it out and let me know if they notice any spookies, I'd really appreciate it!
I'm noticing that even though I'm using the scrollbar bounds as the basis for the minimap bounds, sometimes the height is off. I'll dig into this some more with the debugger
A nice win over VSCode on this one... nice!
@esimkowitz : Will the following features also be implemented?
Vscode:
https://github.com/user-attachments/assets/14977ecb-c905-4bb6-93da-77c508232856
https://github.com/user-attachments/assets/ac618567-4f00-4c1f-9e15-a5233456c559
Xcode:
https://github.com/user-attachments/assets/f1c343d0-ed9c-491e-bb5f-483259d23457
Let's move this to the discussion thread as there's already some context for that there.
which has very simplified rendering
Thinking some more on this, what if we swap every character for a block that is the full width of the em?
I also like the idea of the bracketed highlighting, will look into this. I think this can work well
I do not remember which editor has this option, but you can have either minitext or a simple block per character. This should be a user option, not a fixed change in rendering.
We've discussed this in the discussion thread, yeah VSCode has this option. That should be possible, though not sure how much work it is. We're gonna hold on that for a follow up after getting the designers' input. Let's discuss this further in the discussion thread to keep this PR more focused on feedback for the actual code
Glad you think so, yeah i think settings, mouse input and some little UI tweaks and it should be good to go! Hoping to finish it up this week, I've just been busy with job applications.
Okay, I've added the initial settings I'm planning on using and I've hooked them up and added them to the defaults. I've also added mouse support for the minimap. You should now be able to scroll using your mouse wheel. Clicking on a part of the minimap will navigate to the code section centered under your mouse, matching the behavior of VSCode. Dragging the slider thumb will act more like a traditional scrollbar, also matching how VSCode operates. I think there's still some edge cases with formatting that I need to handle and I don't like how opaque the slider thumb is, but otherwise I think it's feature-complete!
cc @SomeoneToIgnore
Okay I'm marking this PR as ready for review, I have fixed what I believe to be the last layout bug. I still think there's some improvements that can be made to the opacity of the slider thumb, but that feels like something your designers can handle. I think there's also improvements that can be made to how highlights, errors, etc. can be displayed, as well as displaying blocks instead of characters, but those can be fast follows.
Thank you @SomeoneToIgnore for all your assistance!
I have checked the new version and things seem to work for me quite well now, amazing!
I will recheck it better later on Thursday, after the next release, but overall feels that it's indeed quite ready at this state: besides the rebase, I would change the defaults to always show the slider, and might call "thumb" similar to what caret calls it in the code.
This all minor and I can handle it myself later, but welcome to put a few final fixes on top.
Excuse me, I don't know why my local build won't show.
Excuse me, I don't know why my local build won't show.
This is what I see on my end too. Not sure what the difference is between Kirill's and my system where he can see it and I cannot. Strange.
@0x2CA @JosephTLyons weird, yeah I see things fine on my end. What are your editor and scrollbar settings? Also which themes are you using? Note that this feature is currently off by default so you need to enable it in the settings to show it.
@SomeoneToIgnore I fixed the slider naming to thumb as recommended and updated the thumb default, good idea
@0x2CA @JosephTLyons weird, yeah I see things fine on my end. What are your editor and scrollbar settings? Also which themes are you using? Note that this feature is currently off by default so you need to enable it in the settings to show it.
yes, When show is never, Why does one area display a different color?
I'm experiencing a severe performance issue here.
https://github.com/user-attachments/assets/72b7a11d-02c0-40f2-9eb4-cd03240beb0d
And it also caused my vim settings toggle_relative_line_numbers to lose effect
Is it a debug build you're testing?
When show is never, Why does one area display a different color?
It shouldn't, that might be a bug. Will investigate in the morning.
Is it a debug build you're testing?
Okay, the release version doesn't lag, usually I use the debug build.
but for sure,it also caused my vim settings toggle_relative_line_numbers to lose effect
Thank you for rechecking.
Vim settings are interesting, will check more if not fixed before that.
As for perf, there's definitely some #[inline]s (?) we could find and use in debug builds, but personally I am not sure where to put that now.
For the first iteration, if the debug builds work as before for minimap-less settings, I'd consider this an "ok" state for the first iteration.
Do I have to compile a specific branch or is it in main? What is the setting?Am 26.03.2025 um 08:15 schrieb 0x2CA @.***>:
@0x2CA @JosephTLyons weird, yeah I see things fine on my end. What are your editor and scrollbar settings? Also which themes are you using? Note that this feature is currently off by default so you need to enable it in the settings to show it.
yes, When show is never, Why does one area display a different color?—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>
0x2CA left a comment (zed-industries/zed#26893)
@0x2CA @JosephTLyons weird, yeah I see things fine on my end. What are your editor and scrollbar settings? Also which themes are you using? Note that this feature is currently off by default so you need to enable it in the settings to show it.
yes, When show is never, Why does one area display a different color?
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>
@0x2CA I just pushed a potential fix for the vim issue (I think the minimap instance was conflicting and eating the vim bindings so I'm trying to short-circuit the focus handler), can you check if it resolves your problem?
I've also pushed a fix for the bug where the editor width was miscalculated when the minimap was not visible
