fixing autocomplete, bombarded code, nothing in here

This commit is contained in:
filipriec
2025-04-11 22:39:09 +02:00
parent e7e8b0b3f6
commit e145d63ba6
3 changed files with 53 additions and 64 deletions

View File

@@ -80,6 +80,55 @@ pub async fn handle_edit_event(
// Edit-specific actions
if let Some(action) = config.get_edit_action_for_key(key.code, key.modifiers) {
// --- Autocomplete Dropdown Interaction Handling (PRIORITY) ---
if app_state.ui.show_register && register_state.current_field() == 4 && register_state.show_role_suggestions {
match action {
"suggestion_down" => {
let max_index = register_state.role_suggestions.len().saturating_sub(1);
let current_index = register_state.selected_suggestion_index.unwrap_or(0);
register_state.selected_suggestion_index = Some(if current_index >= max_index { 0 } else { current_index + 1 });
return Ok("Suggestion changed".to_string());
}
"suggestion_up" => {
let max_index = register_state.role_suggestions.len().saturating_sub(1);
let current_index = register_state.selected_suggestion_index.unwrap_or(0);
register_state.selected_suggestion_index = Some(if current_index == 0 { max_index } else { current_index.saturating_sub(1) });
return Ok("Suggestion changed".to_string());
}
"select_suggestion" => {
if let Some(selected_index) = register_state.selected_suggestion_index {
if let Some(selected_role) = register_state.role_suggestions.get(selected_index) {
register_state.role = selected_role.clone();
// Hide dropdown after selection
register_state.show_role_suggestions = false;
register_state.selected_suggestion_index = None;
register_state.role_suggestions.clear();
// Move cursor to end of selected role
let new_cursor_pos = register_state.role.len();
register_state.set_current_cursor_pos(new_cursor_pos);
*ideal_cursor_column = new_cursor_pos;
return Ok(format!("Selected role: {}", register_state.role));
}
}
return Ok("No suggestion selected".to_string());
}
"hide_suggestions" => {
register_state.show_role_suggestions = false;
register_state.selected_suggestion_index = None;
return Ok("Suggestions hidden".to_string());
}
// Allow field navigation to hide suggestions
"next_field" | "prev_field" => {
register_state.show_role_suggestions = false;
register_state.selected_suggestion_index = None;
// Fall through to execute the navigation action below
}
_ => {} // Other edit actions might be ignored while dropdown is active
}
}
// --- End Autocomplete Interaction Handling ---
// --- Autocomplete Handling for Role Field ---
if app_state.ui.show_register && register_state.current_field() == 4 {
match action {