Skip rendering gutters when gutter width exceeds view width (#7821)

main
Anshul Dalal 10 months ago committed by GitHub
parent 7cda5b8592
commit c7e9e94f00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -163,15 +163,18 @@ impl EditorView {
Box::new(highlights) Box::new(highlights)
}; };
Self::render_gutter( let gutter_overflow = view.gutter_offset(doc) == 0;
editor, if !gutter_overflow {
doc, Self::render_gutter(
view, editor,
view.area, doc,
theme, view,
is_focused, view.area,
&mut line_decorations, theme,
); is_focused,
&mut line_decorations,
);
}
if is_focused { if is_focused {
let cursor = doc let cursor = doc

@ -187,11 +187,17 @@ impl View {
} }
pub fn gutter_offset(&self, doc: &Document) -> u16 { pub fn gutter_offset(&self, doc: &Document) -> u16 {
self.gutters let total_width = self
.gutters
.layout .layout
.iter() .iter()
.map(|gutter| gutter.width(self, doc) as u16) .map(|gutter| gutter.width(self, doc) as u16)
.sum() .sum();
if total_width < self.area.width {
total_width
} else {
0
}
} }
// //

Loading…
Cancel
Save