edit mode fallbag for not config
This commit is contained in:
@@ -47,9 +47,12 @@ pub async fn handle_edit_event(
|
||||
return Ok((false, "".to_string()));
|
||||
}
|
||||
|
||||
// Try to match against action mappings first
|
||||
// Try to match against configured action mappings first
|
||||
let mut key_sequence_tracker = KeySequenceTracker::new(800);
|
||||
|
||||
// Phase 1: Check for configured key bindings
|
||||
let mut handled_by_config = false;
|
||||
|
||||
if key.modifiers.is_empty() {
|
||||
key_sequence_tracker.add_key(key.code);
|
||||
let sequence = key_sequence_tracker.get_sequence();
|
||||
@@ -65,12 +68,14 @@ pub async fn handle_edit_event(
|
||||
command_message,
|
||||
app_terminal,
|
||||
).await?;
|
||||
handled_by_config = true;
|
||||
return Ok((false, result));
|
||||
}
|
||||
|
||||
// Check if this might be a prefix of a longer sequence
|
||||
if config.is_key_sequence_prefix(&sequence) {
|
||||
// If it's a prefix, wait for more keys
|
||||
handled_by_config = true;
|
||||
return Ok((false, command_message.clone()));
|
||||
}
|
||||
|
||||
@@ -87,6 +92,7 @@ pub async fn handle_edit_event(
|
||||
command_message,
|
||||
app_terminal,
|
||||
).await?;
|
||||
handled_by_config = true;
|
||||
return Ok((false, result));
|
||||
}
|
||||
}
|
||||
@@ -102,27 +108,32 @@ pub async fn handle_edit_event(
|
||||
command_message,
|
||||
app_terminal,
|
||||
).await?;
|
||||
handled_by_config = true;
|
||||
return Ok((false, result));
|
||||
}
|
||||
}
|
||||
|
||||
// If not handled by action mappings, handle edit-specific behavior
|
||||
handle_edit_specific_input(
|
||||
key,
|
||||
form_state,
|
||||
ideal_cursor_column,
|
||||
);
|
||||
// Phase 2: Fallback to default hardcoded behavior only if not handled by configuration
|
||||
if !handled_by_config {
|
||||
// This is now explicitly a fallback for when no config match is found
|
||||
handle_edit_specific_input(
|
||||
key,
|
||||
form_state,
|
||||
ideal_cursor_column,
|
||||
);
|
||||
}
|
||||
|
||||
*edit_mode_cooldown = false;
|
||||
Ok((false, command_message.clone()))
|
||||
}
|
||||
|
||||
// Handle edit-specific key input (character input, backspace, delete)
|
||||
// Handle edit-specific key input as a fallback (character input, backspace, delete)
|
||||
fn handle_edit_specific_input(
|
||||
key: KeyEvent,
|
||||
form_state: &mut FormState,
|
||||
ideal_cursor_column: &mut usize,
|
||||
) {
|
||||
// This is now explicitly a fallback function for default edit behavior
|
||||
match key.code {
|
||||
KeyCode::Char(c) => {
|
||||
// Character input
|
||||
@@ -313,7 +324,7 @@ async fn execute_edit_action(
|
||||
}
|
||||
Ok("".to_string())
|
||||
}
|
||||
// Edit-specific actions (if you want to add keybindings for these operations)
|
||||
// Edit-specific actions that can be bound to keys
|
||||
"delete_char_forward" => {
|
||||
let cursor_pos = form_state.current_cursor_pos;
|
||||
let field_value = form_state.get_current_input_mut();
|
||||
@@ -341,6 +352,11 @@ async fn execute_edit_action(
|
||||
}
|
||||
Ok("".to_string())
|
||||
}
|
||||
"insert_char" => {
|
||||
// This could be expanded to allow configurable character insertion
|
||||
// For now, it's a placeholder that would need additional parameters
|
||||
Ok("Character insertion requires configuration".to_string())
|
||||
}
|
||||
"next_field" => {
|
||||
form_state.current_field = (form_state.current_field + 1) % form_state.fields.len();
|
||||
let current_input = form_state.get_current_input();
|
||||
@@ -359,7 +375,7 @@ async fn execute_edit_action(
|
||||
form_state.current_cursor_pos = (*ideal_cursor_column).min(max_cursor_pos);
|
||||
Ok("".to_string())
|
||||
}
|
||||
// Add more edit mode actions as needed
|
||||
// Fallback for unrecognized actions
|
||||
_ => Ok(format!("Unknown action: {}", action)),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user