Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip rendering gutters when gutter width exceeds view width #7821

Merged
merged 2 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is the right way to go about it or if gutter_offset should return an Option<u16> instead with None in case of overflow

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