i think its a step in the right direction, needs to export other functions now

This commit is contained in:
filipriec
2025-03-23 10:03:59 +01:00
parent ca8dea53fd
commit 87a572783a

View File

@@ -24,6 +24,18 @@ pub async fn handle_edit_event_internal(
handle_edit_specific_input(key, form_state, ideal_cursor_column);
return Ok(command_message.clone());
}
// Check common actions first
if let Some(action) = config.get_action_for_key_in_mode(&config.keybindings.common, key.code, key.modifiers) {
return execute_common_action(
action,
form_state,
grpc_client,
current_position,
total_count,
).await;
}
if let Some(action) = config.get_edit_action_for_key(key.code, key.modifiers) {
return execute_edit_action(
action,
@@ -45,6 +57,27 @@ pub async fn handle_edit_event_internal(
Ok(command_message.clone())
}
async fn execute_common_action(
action: &str,
form_state: &mut FormState,
grpc_client: &mut GrpcClient,
current_position: &mut u64,
total_count: u64,
) -> Result<String, Box<dyn std::error::Error>> {
match action {
"revert" => {
common::revert(
form_state,
grpc_client,
current_position,
total_count,
).await
}
// Add other common actions here if needed
_ => Ok(format!("Common action not handled: {}", action)),
}
}
fn handle_edit_specific_input(
key: KeyEvent,
form_state: &mut FormState,