Skip to content

Commit

Permalink
Skip rendering gutters when gutter width exceeds view width (helix-ed…
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchUsr64 authored and Schuyler Mortimer committed Jul 10, 2024
1 parent 1fa86bb commit a64f317
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
21 changes: 12 additions & 9 deletions helix-term/src/ui/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,18 @@ impl EditorView {
Box::new(highlights)
};

Self::render_gutter(
editor,
doc,
view,
view.area,
theme,
is_focused,
&mut line_decorations,
);
let gutter_overflow = view.gutter_offset(doc) == 0;
if !gutter_overflow {
Self::render_gutter(
editor,
doc,
view,
view.area,
theme,
is_focused,
&mut line_decorations,
);
}

if is_focused {
let cursor = doc
Expand Down
10 changes: 8 additions & 2 deletions helix-view/src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,17 @@ impl View {
}

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

//
Expand Down

0 comments on commit a64f317

Please sign in to comment.