From 87a572783a38d580588da3585a6d42c454958093 Mon Sep 17 00:00:00 2001 From: filipriec Date: Sun, 23 Mar 2025 10:03:59 +0100 Subject: [PATCH] i think its a step in the right direction, needs to export other functions now --- client/src/modes/handlers/edit.rs | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/client/src/modes/handlers/edit.rs b/client/src/modes/handlers/edit.rs index d04e078..09d587b 100644 --- a/client/src/modes/handlers/edit.rs +++ b/client/src/modes/handlers/edit.rs @@ -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> { + 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,