list editor: catch out of bounds in ListEditor::get_item()
This commit is contained in:
parent
7fdc0bf272
commit
2fd209c502
2 changed files with 8 additions and 2 deletions
|
@ -698,7 +698,11 @@ where ItemEditor: TerminalTreeEditor + ?Sized + Send + Sync + 'static,
|
||||||
|
|
||||||
pub fn get_item(&self) -> Option<Arc<RwLock<ItemEditor>>> {
|
pub fn get_item(&self) -> Option<Arc<RwLock<ItemEditor>>> {
|
||||||
if let Some(idx) = self.cursor.get().idx {
|
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 {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,7 +162,9 @@ async fn main() {
|
||||||
process_list_editor.goto_end();
|
process_list_editor.goto_end();
|
||||||
}
|
}
|
||||||
TerminalEvent::Input(Event::Key(Key::Char('\n'))) => {
|
TerminalEvent::Input(Event::Key(Key::Char('\n'))) => {
|
||||||
process_list_editor.get_item().unwrap().write().unwrap().launch_pty2();
|
if let Some(launcher) = process_list_editor.get_item() {
|
||||||
|
launcher.write().unwrap().launch_pty2();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ev => {
|
ev => {
|
||||||
|
|
Loading…
Reference in a new issue