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,10 +698,14 @@ where ItemEditor: TerminalTreeEditor + ?Sized + Send + Sync + 'static,
|
|||
|
||||
pub fn get_item(&self) -> Option<Arc<RwLock<ItemEditor>>> {
|
||||
if let Some(idx) = self.cursor.get().idx {
|
||||
if idx < self.data.len() {
|
||||
Some(self.data.get(idx))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
fn set_idx(&mut self, idx: isize) {
|
||||
|
|
|
@ -162,7 +162,9 @@ async fn main() {
|
|||
process_list_editor.goto_end();
|
||||
}
|
||||
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 => {
|
||||
|
|
Loading…
Reference in a new issue