editor: Do not insert scrollbar hitboxes when scrollbars are never to be shown (#29316)
This PR fixes an issue where scrollbar hitboxes were still inserted for editors despite scrollbars being programmatically disabled via the `show_scrollbars`field. This is basically the same fix as in #27467. The thought process here is that the motivation for `show_scrollbars` is not to just hide the scrollbars in the editor, but to fully disable scrollbars for the associated editor. However, this is currently not the case, as a functioning hitbox for each scrollbar is stil inserted. For example, the behavior with the old assistant panel can be seen below: https://github.com/user-attachments/assets/18af6338-dd28-4794-a6a6-5b9691b243f2 Whilst the scrollbar is not visible, there is still a scrollbar hitbox inserted which triggers hover events and is fully functioning. This PR fixes this by fully skipping the scrollbar layouting whenever `show_scrollbars` is set to false, preventing the hitboxes from being inserted. https://github.com/user-attachments/assets/b6bb6dc7-902f-4383-bf03-506d0a57ec77 Release Notes: - N/A
This commit is contained in:
parent
3b90d62bb2
commit
6bacea28bc
1 changed files with 30 additions and 31 deletions
|
@ -1449,7 +1449,7 @@ impl EditorElement {
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut App,
|
cx: &mut App,
|
||||||
) -> Option<EditorScrollbars> {
|
) -> Option<EditorScrollbars> {
|
||||||
if !snapshot.mode.is_full() {
|
if !snapshot.mode.is_full() || !self.editor.read(cx).show_scrollbars {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1462,36 +1462,35 @@ impl EditorElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
let scrollbar_settings = EditorSettings::get_global(cx).scrollbar;
|
let scrollbar_settings = EditorSettings::get_global(cx).scrollbar;
|
||||||
let show_scrollbars = self.editor.read(cx).show_scrollbars
|
let show_scrollbars = match scrollbar_settings.show {
|
||||||
&& match scrollbar_settings.show {
|
ShowScrollbar::Auto => {
|
||||||
ShowScrollbar::Auto => {
|
let editor = self.editor.read(cx);
|
||||||
let editor = self.editor.read(cx);
|
let is_singleton = editor.is_singleton(cx);
|
||||||
let is_singleton = editor.is_singleton(cx);
|
// Git
|
||||||
// Git
|
(is_singleton && scrollbar_settings.git_diff && snapshot.buffer_snapshot.has_diff_hunks())
|
||||||
(is_singleton && scrollbar_settings.git_diff && snapshot.buffer_snapshot.has_diff_hunks())
|
||
|
||||||
||
|
// Buffer Search Results
|
||||||
// Buffer Search Results
|
(is_singleton && scrollbar_settings.search_results && editor.has_background_highlights::<BufferSearchHighlights>())
|
||||||
(is_singleton && scrollbar_settings.search_results && editor.has_background_highlights::<BufferSearchHighlights>())
|
||
|
||||||
||
|
// Selected Text Occurrences
|
||||||
// Selected Text Occurrences
|
(is_singleton && scrollbar_settings.selected_text && editor.has_background_highlights::<SelectedTextHighlight>())
|
||||||
(is_singleton && scrollbar_settings.selected_text && editor.has_background_highlights::<SelectedTextHighlight>())
|
||
|
||||||
||
|
// Selected Symbol Occurrences
|
||||||
// Selected Symbol Occurrences
|
(is_singleton && scrollbar_settings.selected_symbol && (editor.has_background_highlights::<DocumentHighlightRead>() || editor.has_background_highlights::<DocumentHighlightWrite>()))
|
||||||
(is_singleton && scrollbar_settings.selected_symbol && (editor.has_background_highlights::<DocumentHighlightRead>() || editor.has_background_highlights::<DocumentHighlightWrite>()))
|
||
|
||||||
||
|
// Diagnostics
|
||||||
// Diagnostics
|
(is_singleton && scrollbar_settings.diagnostics != ScrollbarDiagnostics::None && snapshot.buffer_snapshot.has_diagnostics())
|
||||||
(is_singleton && scrollbar_settings.diagnostics != ScrollbarDiagnostics::None && snapshot.buffer_snapshot.has_diagnostics())
|
||
|
||||||
||
|
// Cursors out of sight
|
||||||
// Cursors out of sight
|
non_visible_cursors
|
||||||
non_visible_cursors
|
||
|
||||||
||
|
// Scrollmanager
|
||||||
// Scrollmanager
|
editor.scroll_manager.scrollbars_visible()
|
||||||
editor.scroll_manager.scrollbars_visible()
|
}
|
||||||
}
|
ShowScrollbar::System => self.editor.read(cx).scroll_manager.scrollbars_visible(),
|
||||||
ShowScrollbar::System => self.editor.read(cx).scroll_manager.scrollbars_visible(),
|
ShowScrollbar::Always => true,
|
||||||
ShowScrollbar::Always => true,
|
ShowScrollbar::Never => return None,
|
||||||
ShowScrollbar::Never => return None,
|
};
|
||||||
};
|
|
||||||
|
|
||||||
Some(EditorScrollbars::from_scrollbar_axes(
|
Some(EditorScrollbars::from_scrollbar_axes(
|
||||||
scrollbar_settings.axes,
|
scrollbar_settings.axes,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue