diff --git a/local/recipes/tui/tlc/source/src/editor/mod.rs b/local/recipes/tui/tlc/source/src/editor/mod.rs index 3bea5c047f..126e2136d3 100644 --- a/local/recipes/tui/tlc/source/src/editor/mod.rs +++ b/local/recipes/tui/tlc/source/src/editor/mod.rs @@ -3873,5 +3873,45 @@ mod tests { e.push_goto_history(20); assert_eq!(e.goto_history, vec![10, 20]); } + + #[test] + fn mark_all_selects_entire_buffer() { + let mut e = make_empty(); + e.insert_str("hello world"); + // Dispatch MarkAll via the dispatcher. + let _ = e.dispatch_editor_cmd(crate::editor::menubar::EditorCmd::MarkAll); + let sel = e.cursor.selection(); + assert!(sel.is_some()); + let (start, end) = sel.unwrap(); + assert_eq!(start, 0); + assert_eq!(end, e.buffer.len()); + } + + #[test] + fn close_clean_buffer_reopens_empty() { + let mut e = make_empty(); + e.insert_str("hello"); + e.modified = false; + let _ = e.dispatch_editor_cmd(crate::editor::menubar::EditorCmd::Close); + // Should have reopened as an empty buffer. + assert_eq!(e.buffer.len(), 0); + assert!(!e.modified); + } + + #[test] + fn block_save_on_no_selection_shows_message() { + let mut e = make_empty(); + e.insert_str("hello"); + e.cursor.clear_selection(); + let _ = e.dispatch_editor_cmd(crate::editor::menubar::EditorCmd::BlockSave); + assert_eq!(e.message, Some("No selection".to_string())); + } + + #[test] + fn insert_file_opens_insert_file_prompt() { + let mut e = make_empty(); + let _ = e.dispatch_editor_cmd(crate::editor::menubar::EditorCmd::InsertFile); + assert!(e.mode.is_prompt()); + } }