From a4e94878e7153419935b3213b12a2fc6c8ae4565 Mon Sep 17 00:00:00 2001 From: filipriec Date: Sat, 26 Jul 2025 22:30:45 +0200 Subject: [PATCH] enter decider should be taken care of next, suggestions works in register now also --- client/config.toml | 2 +- client/src/functions/modes/edit/auth_e.rs | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/client/config.toml b/client/config.toml index a8462dd..cf791d2 100644 --- a/client/config.toml +++ b/client/config.toml @@ -74,7 +74,7 @@ move_left = [""] move_right = ["right"] suggestion_down = ["ctrl+n", "tab"] suggestion_up = ["ctrl+p", "shift+tab"] -trigger_autocomplete = ["tab"] +trigger_autocomplete = ["left"] [keybindings.command] exit_command_mode = ["ctrl+g", "esc"] diff --git a/client/src/functions/modes/edit/auth_e.rs b/client/src/functions/modes/edit/auth_e.rs index 68b2301..9c717cf 100644 --- a/client/src/functions/modes/edit/auth_e.rs +++ b/client/src/functions/modes/edit/auth_e.rs @@ -291,6 +291,28 @@ pub async fn execute_edit_action( Ok("Moved to previous word end".to_string()) } + "trigger_autocomplete" => { + if let Some(register_state) = (state as &mut dyn Any).downcast_mut::() { + if register_state.current_field() == 4 { // Role field + register_state.update_role_suggestions(); + + if !register_state.role_suggestions.is_empty() { + register_state.in_suggestion_mode = true; + register_state.show_role_suggestions = true; + register_state.selected_suggestion_index = Some(0); + + return Ok("Autocomplete activated".to_string()); + } else { + return Ok("No suggestions available".to_string()); + } + } else { + return Ok("Autocomplete only available on role field".to_string()); + } + } else { + return Ok("Autocomplete not supported for this state".to_string()); + } + } + // --- Autocomplete Actions --- "suggestion_down" | "suggestion_up" | "select_suggestion" | "exit_suggestion_mode" => { // Attempt to downcast to RegisterState to handle suggestion logic here