command mode entering during edit mode is now forbidden
This commit is contained in:
@@ -272,6 +272,7 @@ impl Config {
|
||||
}
|
||||
|
||||
/// Checks if a key is bound to entering Command mode.
|
||||
/// This method is no longer used in event.rs since we now handle command mode entry only in read-only mode directly.
|
||||
pub fn is_enter_command_mode(&self, key: KeyCode, modifiers: KeyModifiers) -> bool {
|
||||
if let Some(bindings) = self.keybindings.command.get("enter_command_mode") {
|
||||
bindings.iter().any(|b| Self::matches_keybinding(b, key, modifiers))
|
||||
@@ -280,6 +281,7 @@ impl Config {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Checks if a key is bound to exiting Command mode.
|
||||
pub fn is_exit_command_mode(&self, key: KeyCode, modifiers: KeyModifiers) -> bool {
|
||||
if let Some(bindings) = self.keybindings.command.get("exit_command_mode") {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user