diff --git a/nested/src/list/editor.rs b/nested/src/list/editor.rs index e80d43a..261efe9 100644 --- a/nested/src/list/editor.rs +++ b/nested/src/list/editor.rs @@ -698,7 +698,11 @@ where ItemEditor: TerminalTreeEditor + ?Sized + Send + Sync + 'static, pub fn get_item(&self) -> Option>> { 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 } diff --git a/shell/src/main.rs b/shell/src/main.rs index c53f5ab..004e164 100644 --- a/shell/src/main.rs +++ b/shell/src/main.rs @@ -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 => {