mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Fix panic with mouse click in TextArea
This commit is contained in:
parent
0490ba0f38
commit
9026d87aab
@ -1,5 +1,4 @@
|
|||||||
|
use std::cmp::min;
|
||||||
|
|
||||||
use {Printer, With, XY};
|
use {Printer, With, XY};
|
||||||
use direction::Direction;
|
use direction::Direction;
|
||||||
use event::{Event, EventResult, Key, MouseEvent};
|
use event::{Event, EventResult, Key, MouseEvent};
|
||||||
@ -472,7 +471,12 @@ impl View for TextArea {
|
|||||||
) =>
|
) =>
|
||||||
{
|
{
|
||||||
position.checked_sub(offset).map(|position| {
|
position.checked_sub(offset).map(|position| {
|
||||||
|
if self.rows.is_empty() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let y = position.y + self.scrollbase.start_line;
|
let y = position.y + self.scrollbase.start_line;
|
||||||
|
let y = min(y, self.rows.len() - 1);
|
||||||
let x = position.x;
|
let x = position.x;
|
||||||
let row = &self.rows[y];
|
let row = &self.rows[y];
|
||||||
let content = &self.content[row.start..row.end];
|
let content = &self.content[row.start..row.end];
|
||||||
|
Loading…
Reference in New Issue
Block a user