command mode entering during edit mode is now forbidden

This commit is contained in:
filipriec
2025-02-28 21:39:27 +01:00
parent cd3c6fd71f
commit 18be34b336
3 changed files with 27 additions and 14 deletions

View File

@@ -67,16 +67,11 @@ impl EventHandler {
return Ok((false, String::new()));
}
// Check for entering command mode from any other mode
if config.is_enter_command_mode(key.code, key.modifiers) {
self.command_mode = true;
self.command_input.clear();
self.command_message.clear();
return Ok((false, String::new()));
}
// Mode transitions between edit mode and read-only mode
// Mode transitions and mode-specific handling
if self.is_edit_mode {
// When in EDIT mode, we DON'T want to check for entering command mode
// as ':' should just be a normal character input
// Check for exiting edit mode
if config.is_exit_edit_mode(key.code, key.modifiers) {
if form_state.has_unsaved_changes {
@@ -108,6 +103,18 @@ impl EventHandler {
self.key_sequence_tracker.reset();
return Ok((false, result));
} else {
// In READ-ONLY mode, we DO want to check for entering command mode
// Check for entering command mode (only in read-only mode)
// Use get_read_only_action_for_key instead of is_enter_command_mode
if let Some(action) = config.get_read_only_action_for_key(key.code, key.modifiers) {
if action == "enter_command_mode" {
self.command_mode = true;
self.command_input.clear();
self.command_message.clear();
return Ok((false, String::new()));
}
}
// Check for entering edit mode from read-only mode
if config.is_enter_edit_mode_before(key.code, key.modifiers) {
self.is_edit_mode = true;