list editor: catch out of bounds in ListEditor::get_item()

This commit is contained in:
Michael Sippel 2021-11-07 08:50:36 +01:00
parent 7fdc0bf272
commit 2fd209c502
Signed by: senvas
GPG key ID: F96CF119C34B64A6
2 changed files with 8 additions and 2 deletions
nested/src/list

View file

@ -698,7 +698,11 @@ where ItemEditor: TerminalTreeEditor + ?Sized + Send + Sync + 'static,
pub fn get_item(&self) -> Option<Arc<RwLock<ItemEditor>>> {
if let Some(idx) = self.cursor.get().idx {
Some(self.data.get(idx))
if idx < self.data.len() {
Some(self.data.get(idx))
} else {
None
}
} else {
None
}