disabling : in the edit mode
This commit is contained in:
@@ -21,6 +21,32 @@ pub async fn handle_edit_event(
|
|||||||
current_position: &mut u64,
|
current_position: &mut u64,
|
||||||
total_count: u64,
|
total_count: u64,
|
||||||
) -> Result<(bool, String), Box<dyn std::error::Error>> {
|
) -> Result<(bool, String), Box<dyn std::error::Error>> {
|
||||||
|
// Handle command mode if already in it
|
||||||
|
if *command_mode {
|
||||||
|
let (should_exit, message, exit_command_mode) = handle_command_event(
|
||||||
|
key,
|
||||||
|
config,
|
||||||
|
form_state,
|
||||||
|
command_input,
|
||||||
|
command_message,
|
||||||
|
app_terminal,
|
||||||
|
is_saved,
|
||||||
|
current_position,
|
||||||
|
total_count,
|
||||||
|
).await?;
|
||||||
|
|
||||||
|
if exit_command_mode {
|
||||||
|
*command_mode = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if !message.is_empty() {
|
||||||
|
return Ok((should_exit, message));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok((false, "".to_string()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Regular edit mode handling
|
||||||
match key.code {
|
match key.code {
|
||||||
KeyCode::Left => {
|
KeyCode::Left => {
|
||||||
form_state.current_cursor_pos = form_state.current_cursor_pos.saturating_sub(1);
|
form_state.current_cursor_pos = form_state.current_cursor_pos.saturating_sub(1);
|
||||||
@@ -35,12 +61,6 @@ pub async fn handle_edit_event(
|
|||||||
}
|
}
|
||||||
return Ok((false, "".to_string()));
|
return Ok((false, "".to_string()));
|
||||||
}
|
}
|
||||||
KeyCode::Char(':') => {
|
|
||||||
*command_mode = true;
|
|
||||||
command_input.clear();
|
|
||||||
command_message.clear();
|
|
||||||
return Ok((false, "".to_string()));
|
|
||||||
}
|
|
||||||
KeyCode::Esc => {
|
KeyCode::Esc => {
|
||||||
if config.is_exit_edit_mode(key.code, key.modifiers) {
|
if config.is_exit_edit_mode(key.code, key.modifiers) {
|
||||||
if form_state.has_unsaved_changes {
|
if form_state.has_unsaved_changes {
|
||||||
@@ -107,6 +127,7 @@ pub async fn handle_edit_event(
|
|||||||
form_state.current_cursor_pos = (*ideal_cursor_column).min(max_cursor_pos);
|
form_state.current_cursor_pos = (*ideal_cursor_column).min(max_cursor_pos);
|
||||||
}
|
}
|
||||||
KeyCode::Char(c) => {
|
KeyCode::Char(c) => {
|
||||||
|
// In edit mode, ':' is just a normal character
|
||||||
let cursor_pos = form_state.current_cursor_pos;
|
let cursor_pos = form_state.current_cursor_pos;
|
||||||
let field_value = form_state.get_current_input_mut();
|
let field_value = form_state.get_current_input_mut();
|
||||||
let mut chars: Vec<char> = field_value.chars().collect();
|
let mut chars: Vec<char> = field_value.chars().collect();
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ impl EventHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub async fn handle_event(
|
pub async fn handle_event(
|
||||||
&mut self,
|
&mut self,
|
||||||
event: Event,
|
event: Event,
|
||||||
@@ -74,8 +75,8 @@ impl EventHandler {
|
|||||||
return Ok((false, "".to_string()));
|
return Ok((false, "".to_string()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Handle special case: Entering command mode with ":"
|
// Only trigger command mode with ":" in read-only mode, not in edit mode
|
||||||
else if key.code == KeyCode::Char(':') {
|
else if !self.is_edit_mode && key.code == KeyCode::Char(':') {
|
||||||
self.command_mode = true;
|
self.command_mode = true;
|
||||||
self.command_input.clear();
|
self.command_input.clear();
|
||||||
self.command_message.clear();
|
self.command_message.clear();
|
||||||
|
|||||||
Reference in New Issue
Block a user