editor: Ensure minimap is shown when show_minimap
is toggled to true
(#30326)
Follow-up of #30285 This PR ensures the action added in the linked PR also works when the user does not have the minimap enabled via settings. Currently, the toggle only works when the user has already enabled the minimap in their settings. This happens because inb4fbb9bc08/crates/editor/src/element.rs (L7160-L7164)
as well asb4fbb9bc08/crates/editor/src/element.rs (L1542)
we check for the user configuration before reserving space for the minimap as well as layouting it and because inb4fbb9bc08/crates/editor/src/editor.rs (L16404)
withb4fbb9bc08/crates/editor/src/editor_settings.rs (L132-L134)
we would not even create a minimap when the user disabled it via their settings. --- This PR fixes this by ensuring a minimap is created on the toggle issue as well as lifting some of the restrictions. Since we are always only returning a minimap inb4fbb9bc08/crates/editor/src/editor.rs (L16443-L16445)
when `show_minimap` is set to `true`, we can assume in the rendering code that if a minimap is present, it should be layouted and rendered no matter if `ShowMinimap` is currently set to `Never`. We can do this since `show_minimap` always reflects the current user configuration, seeb4fbb9bc08/crates/editor/src/editor.rs (L18163-L18164)
I also removed the minimap deletion/recreation on the toggling of `show_minimap`, since this is not really needed - once we have stored a minimap editor within the editor, `show_minimap` is sufficient to ensure that it is only shown when the user requests it. Notice that we still will never create a minimap unless neccesary. Lastly, I updated the `supports_minimap` check to account for the fact that the minimap is currently disabled entirely for multibuffers. --- One thing I ~~did not tackle here~~ tackled in the second commit is that due to `show_minimap` now being exposed to the user, it is possible to enable the minimap for all full mode editors, e.g. the agent text thread editor <img width="592" alt="grafik" src="https://github.com/user-attachments/assets/5f6c0e8b-45f9-44e8-9625-9d51c1480f98" /> which should most likely not be possible when the minimap is programmatically disabled. Release Notes: - N/A
This commit is contained in:
parent
29c31f020e
commit
1ecd00a113
4 changed files with 72 additions and 24 deletions
|
@ -105,7 +105,7 @@ impl Render for QuickActionBar {
|
|||
let show_edit_predictions = editor_value.edit_predictions_enabled();
|
||||
let edit_predictions_enabled_at_cursor =
|
||||
editor_value.edit_predictions_enabled_at_cursor(cx);
|
||||
let supports_minimap = editor_value.supports_minimap();
|
||||
let supports_minimap = editor_value.supports_minimap(cx);
|
||||
let minimap_enabled = supports_minimap && editor_value.minimap().is_some();
|
||||
|
||||
let focus_handle = editor_value.focus_handle(cx);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue