Fix perf problem with scrollbars in large multibuffers (#2505)
Remove scrollbars from multibuffers Release Notes: * Removes git scrollbar highlights from multibuffers (preview only)
This commit is contained in:
parent
5a2b819c18
commit
c1b3d389ba
4 changed files with 66 additions and 51 deletions
|
@ -518,11 +518,8 @@ pub struct EditorSnapshot {
|
|||
}
|
||||
|
||||
impl EditorSnapshot {
|
||||
fn has_scrollbar_info(&self) -> bool {
|
||||
self.buffer_snapshot
|
||||
.git_diff_hunks_in_range(0..self.max_point().row())
|
||||
.next()
|
||||
.is_some()
|
||||
fn has_scrollbar_info(&self, is_singleton: bool) -> bool {
|
||||
is_singleton && self.buffer_snapshot.has_git_diffs()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1047,7 +1047,8 @@ impl EditorElement {
|
|||
..Default::default()
|
||||
});
|
||||
|
||||
let diff_style = cx.global::<Settings>().theme.editor.diff.clone();
|
||||
if layout.is_singleton {
|
||||
let diff_style = theme::current(cx).editor.diff.clone();
|
||||
for hunk in layout
|
||||
.position_map
|
||||
.snapshot
|
||||
|
@ -1093,6 +1094,7 @@ impl EditorElement {
|
|||
corner_radius: style.thumb.corner_radius,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
scene.push_quad(Quad {
|
||||
bounds: thumb_bounds,
|
||||
|
@ -2063,9 +2065,10 @@ impl Element<Editor> for EditorElement {
|
|||
));
|
||||
}
|
||||
|
||||
let show_scrollbars = match cx.global::<Settings>().show_scrollbars {
|
||||
settings::ShowScrollbars::Auto => {
|
||||
snapshot.has_scrollbar_info() || editor.scroll_manager.scrollbars_visible()
|
||||
let show_scrollbars = match settings::get::<EditorSettings>(cx).show_scrollbars {
|
||||
ShowScrollbars::Auto => {
|
||||
snapshot.has_scrollbar_info(is_singleton)
|
||||
|| editor.scroll_manager.scrollbars_visible()
|
||||
}
|
||||
settings::ShowScrollbars::System => editor.scroll_manager.scrollbars_visible(),
|
||||
settings::ShowScrollbars::Always => true,
|
||||
|
@ -2288,6 +2291,7 @@ impl Element<Editor> for EditorElement {
|
|||
text_size,
|
||||
scrollbar_row_range,
|
||||
show_scrollbars,
|
||||
is_singleton,
|
||||
max_row,
|
||||
gutter_margin,
|
||||
active_rows,
|
||||
|
@ -2443,6 +2447,7 @@ pub struct LayoutState {
|
|||
selections: Vec<(ReplicaId, Vec<SelectionLayout>)>,
|
||||
scrollbar_row_range: Range<f32>,
|
||||
show_scrollbars: bool,
|
||||
is_singleton: bool,
|
||||
max_row: u32,
|
||||
context_menu: Option<(DisplayPoint, AnyElement<Editor>)>,
|
||||
code_actions_indicator: Option<(u32, AnyElement<Editor>)>,
|
||||
|
|
|
@ -2820,6 +2820,15 @@ impl MultiBufferSnapshot {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn has_git_diffs(&self) -> bool {
|
||||
for excerpt in self.excerpts.iter() {
|
||||
if !excerpt.buffer.git_diff.is_empty() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
pub fn git_diff_hunks_in_range_rev<'a>(
|
||||
&'a self,
|
||||
row_range: Range<u32>,
|
||||
|
|
|
@ -71,6 +71,10 @@ impl BufferDiff {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.tree.is_empty()
|
||||
}
|
||||
|
||||
pub fn hunks_in_row_range<'a>(
|
||||
&'a self,
|
||||
range: Range<u32>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue