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

Fix lacking space panic #6109

Merged
merged 10 commits into from
Mar 5, 2023
5 changes: 1 addition & 4 deletions helix-term/src/ui/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,13 +342,10 @@ impl Component for Markdown {

fn required_size(&mut self, viewport: (u16, u16)) -> Option<(u16, u16)> {
let padding = 2;
if padding >= viewport.1 || padding >= viewport.0 {
return None;
}
nuid64 marked this conversation as resolved.
Show resolved Hide resolved
let contents = self.parse(None);

// TODO: account for tab width
let max_text_width = (viewport.0 - padding).min(120);
let max_text_width = (viewport.0.saturating_sub(padding)).min(120);
let (width, height) = crate::ui::text::required_size(&contents, max_text_width);

Some((width + padding, height + padding))
Expand Down
10 changes: 7 additions & 3 deletions helix-tui/src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,13 @@ impl Buffer {
pub fn clear_with(&mut self, area: Rect, style: Style) {
for x in area.left()..area.right() {
for y in area.top()..area.bottom() {
let cell = &mut self[(x, y)];
cell.reset();
cell.set_style(style);
if let Some(cell) = &mut self.get_mut(x, y) {
nuid64 marked this conversation as resolved.
Show resolved Hide resolved
cell.reset();
cell.set_style(style);
} else {
// Skip this render if the window size has changed
continue;
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions helix-view/src/graphics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ impl Rect {
Rect {
x: x1,
y: y1,
width: x2 - x1,
height: y2 - y1,
width: x2.saturating_sub(x1),
height: y2.saturating_sub(y1),
}
}

Expand Down