command mode entering during edit mode is now forbidden
This commit is contained in:
@@ -2,10 +2,10 @@
|
||||
[keybindings]
|
||||
|
||||
[keybindings.common]
|
||||
save = [":w", "ctrl+s"]
|
||||
quit = [":q", "ctrl+q"]
|
||||
force_quit = [":q!", "ctrl+shift+q"]
|
||||
save_and_quit = [":wq", "ctrl+shift+s"]
|
||||
save = ["ctrl+s"]
|
||||
quit = ["ctrl+q"]
|
||||
force_quit = ["ctrl+shift+q"]
|
||||
save_and_quit = ["ctrl+shift+s"]
|
||||
move_up = ["Up"]
|
||||
move_down = ["Down"]
|
||||
|
||||
@@ -29,6 +29,7 @@ move_line_start = ["0"]
|
||||
move_line_end = ["$"]
|
||||
move_first_line = ["gg"]
|
||||
move_last_line = ["x"]
|
||||
enter_command_mode = [":", "ctrl+;"]
|
||||
|
||||
[keybindings.edit]
|
||||
exit_edit_mode = ["esc","ctrl+e"]
|
||||
@@ -43,7 +44,10 @@ move_right = ["right"]
|
||||
exit_command_mode = ["ctrl+g", "esc"]
|
||||
command_execute = ["enter"]
|
||||
command_backspace = ["backspace"]
|
||||
enter_command_mode = [":", "ctrl+;"]
|
||||
save = ["w"]
|
||||
quit = ["q"]
|
||||
force_quit = ["q!"]
|
||||
save_and_quit = ["wq"]
|
||||
|
||||
[colors]
|
||||
theme = "dark"
|
||||
|
||||
@@ -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