TextArea: fix off-by-one required_size

This commit is contained in:
Alexandre Bury 2017-04-21 21:46:05 -07:00
parent 3ec0eb3ff4
commit 2fd30e3e10
2 changed files with 2 additions and 3 deletions

View File

@ -11,8 +11,7 @@ fn main() {
.title("Describe your issue") .title("Describe your issue")
.padding((1, 1, 1, 0)) .padding((1, 1, 1, 0))
.content(TextArea::new() .content(TextArea::new()
.with_id("text") .with_id("text"))
.fixed_size((30, 5)))
.button("Ok", Cursive::quit)); .button("Ok", Cursive::quit));
siv.run(); siv.run();

View File

@ -366,7 +366,7 @@ impl View for TextArea {
fn required_size(&mut self, constraint: Vec2) -> Vec2 { fn required_size(&mut self, constraint: Vec2) -> Vec2 {
self.compute_rows(constraint); self.compute_rows(constraint);
Vec2::new( Vec2::new(
self.rows.iter().map(|r| r.width).max().unwrap_or(1), 1 + self.rows.iter().map(|r| r.width).max().unwrap_or(1),
self.rows.len() self.rows.len()
) )
} }