feat(ui): add buffers HashMap for text input state management
Introduce a buffers HashMap to manage text input state across different modes (command, edit, formula, category, export). Changes: - Added buffers field to GridWidget and updated constructor - Updated draw_command_bar to use app.buffers instead of mode buffer - Updated grid edit indicator to use buffers HashMap - Added tests for command mode buffer behavior: * command_mode_typing_appends_to_buffer * command_mode_buffer_cleared_on_reentry Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/Qwen3.5-35B-A3B-GGUF:Q5_K_M)
This commit is contained in:
@ -290,4 +290,39 @@ mod tests {
|
||||
"mode must not be Normal after import wizard is opened"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn command_mode_typing_appends_to_buffer() {
|
||||
use crossterm::event::KeyEvent;
|
||||
let mut app = two_col_model();
|
||||
// Enter command mode with ':'
|
||||
app.handle_key(KeyEvent::new(KeyCode::Char(':'), KeyModifiers::NONE))
|
||||
.unwrap();
|
||||
assert!(matches!(app.mode, AppMode::CommandMode { .. }));
|
||||
assert_eq!(app.buffers.get("command").map(|s| s.as_str()), Some(""));
|
||||
|
||||
// Type 'q'
|
||||
app.handle_key(KeyEvent::new(KeyCode::Char('q'), KeyModifiers::NONE))
|
||||
.unwrap();
|
||||
assert_eq!(app.buffers.get("command").map(|s| s.as_str()), Some("q"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn command_mode_buffer_cleared_on_reentry() {
|
||||
use crossterm::event::KeyEvent;
|
||||
let mut app = two_col_model();
|
||||
// Enter command mode, type something, escape
|
||||
app.handle_key(KeyEvent::new(KeyCode::Char(':'), KeyModifiers::NONE))
|
||||
.unwrap();
|
||||
app.handle_key(KeyEvent::new(KeyCode::Char('x'), KeyModifiers::NONE))
|
||||
.unwrap();
|
||||
assert_eq!(app.buffers.get("command").map(|s| s.as_str()), Some("x"));
|
||||
app.handle_key(KeyEvent::new(KeyCode::Esc, KeyModifiers::NONE))
|
||||
.unwrap();
|
||||
|
||||
// Re-enter command mode — buffer should be cleared
|
||||
app.handle_key(KeyEvent::new(KeyCode::Char(':'), KeyModifiers::NONE))
|
||||
.unwrap();
|
||||
assert_eq!(app.buffers.get("command").map(|s| s.as_str()), Some(""));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user