tab is triggering the suggestion dropdown menu, but ctrl+n and ctrl+p only cycle through it
This commit is contained in:
@@ -51,11 +51,11 @@ exit_edit_mode = ["esc","ctrl+e"]
|
|||||||
delete_char_forward = ["delete"]
|
delete_char_forward = ["delete"]
|
||||||
delete_char_backward = ["backspace"]
|
delete_char_backward = ["backspace"]
|
||||||
next_field = ["enter"]
|
next_field = ["enter"]
|
||||||
prev_field = ["backtab"]
|
prev_field = ["shift+enter"]
|
||||||
move_left = ["left"]
|
move_left = ["left"]
|
||||||
move_right = ["right"]
|
move_right = ["right"]
|
||||||
suggestion_down = ["shift+tab"]
|
suggestion_down = ["ctrl+n", "tab"]
|
||||||
suggestion_up = ["tab"]
|
suggestion_up = ["ctrl+p", "shift+tab"]
|
||||||
select_suggestion = ["enter"]
|
select_suggestion = ["enter"]
|
||||||
exit_suggestion_mode = ["esc"]
|
exit_suggestion_mode = ["esc"]
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use crate::{
|
|||||||
components::common::{dialog, autocomplete},
|
components::common::{dialog, autocomplete},
|
||||||
state::state::AppState,
|
state::state::AppState,
|
||||||
state::canvas_state::CanvasState,
|
state::canvas_state::CanvasState,
|
||||||
|
modes::handlers::mode_manager::AppMode,
|
||||||
};
|
};
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
layout::{Alignment, Constraint, Direction, Layout, Rect, Margin},
|
layout::{Alignment, Constraint, Direction, Layout, Rect, Margin},
|
||||||
@@ -136,11 +137,13 @@ pub fn render_register(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// --- Render Autocomplete Dropdown (Draw AFTER buttons) ---
|
// --- Render Autocomplete Dropdown (Draw AFTER buttons) ---
|
||||||
if let Some(suggestions) = state.get_suggestions() {
|
if app_state.current_mode == AppMode::Edit {
|
||||||
let selected = state.get_selected_suggestion_index();
|
if let Some(suggestions) = state.get_suggestions() {
|
||||||
if !suggestions.is_empty() {
|
let selected = state.get_selected_suggestion_index();
|
||||||
if let Some(input_rect) = active_field_rect {
|
if !suggestions.is_empty() {
|
||||||
autocomplete::render_autocomplete_dropdown(f, input_rect, f.size(), theme, suggestions, selected);
|
if let Some(input_rect) = active_field_rect {
|
||||||
|
autocomplete::render_autocomplete_dropdown(f, input_rect, f.size(), theme, suggestions, selected);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -311,7 +311,7 @@ pub async fn execute_edit_action<S: CanvasState + Any + Send>(
|
|||||||
register_state.selected_suggestion_index = Some(if current_index >= max_index { 0 } else { current_index + 1 });
|
register_state.selected_suggestion_index = Some(if current_index >= max_index { 0 } else { current_index + 1 });
|
||||||
Ok("Suggestion changed down".to_string())
|
Ok("Suggestion changed down".to_string())
|
||||||
}
|
}
|
||||||
"suggestion_up" if register_state.show_role_suggestions => {
|
"suggestion_up" if register_state.in_suggestion_mode => {
|
||||||
let max_index = register_state.role_suggestions.len().saturating_sub(1);
|
let max_index = register_state.role_suggestions.len().saturating_sub(1);
|
||||||
let current_index = register_state.selected_suggestion_index.unwrap_or(0);
|
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) });
|
register_state.selected_suggestion_index = Some(if current_index == 0 { max_index } else { current_index.saturating_sub(1) });
|
||||||
@@ -336,10 +336,12 @@ pub async fn execute_edit_action<S: CanvasState + Any + Send>(
|
|||||||
register_state.in_suggestion_mode = false;
|
register_state.in_suggestion_mode = false;
|
||||||
Ok("Suggestions hidden".to_string())
|
Ok("Suggestions hidden".to_string())
|
||||||
}
|
}
|
||||||
_ => Ok("".to_string()) // Action doesn't apply in this state (e.g., suggestions not shown)
|
"suggestion_down" | "suggestion_up" | "select_suggestion" => {
|
||||||
|
Ok("Suggestion action ignored: Not in suggestion mode.".to_string())
|
||||||
|
}
|
||||||
|
_ => Ok("".to_string())
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Action received but not applicable to the current field
|
|
||||||
Ok("".to_string())
|
Ok("".to_string())
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use crate::state::pages::form::FormState;
|
|||||||
use crate::functions::modes::edit::{auth_e, form_e};
|
use crate::functions::modes::edit::{auth_e, form_e};
|
||||||
use crate::modes::handlers::event::EventOutcome;
|
use crate::modes::handlers::event::EventOutcome;
|
||||||
use crate::state::state::AppState;
|
use crate::state::state::AppState;
|
||||||
use crossterm::event::{KeyCode, KeyEvent};
|
use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
|
||||||
|
|
||||||
pub async fn handle_edit_event(
|
pub async fn handle_edit_event(
|
||||||
key: KeyEvent,
|
key: KeyEvent,
|
||||||
@@ -82,20 +82,15 @@ pub async fn handle_edit_event(
|
|||||||
if let Some(action) = config.get_edit_action_for_key(key.code, key.modifiers) {
|
if let Some(action) = config.get_edit_action_for_key(key.code, key.modifiers) {
|
||||||
// --- Special Handling for Tab/Shift+Tab in Role Field ---
|
// --- Special Handling for Tab/Shift+Tab in Role Field ---
|
||||||
if app_state.ui.show_register && register_state.current_field() == 4 {
|
if app_state.ui.show_register && register_state.current_field() == 4 {
|
||||||
match action {
|
if !register_state.in_suggestion_mode && key.code == KeyCode::Tab && key.modifiers == KeyModifiers::NONE {
|
||||||
"suggestion_up" | "suggestion_down" => { // Mapped to Tab/Shift+Tab
|
register_state.update_role_suggestions();
|
||||||
if !register_state.in_suggestion_mode {
|
if !register_state.role_suggestions.is_empty() {
|
||||||
register_state.update_role_suggestions();
|
register_state.in_suggestion_mode = true;
|
||||||
if !register_state.role_suggestions.is_empty() {
|
register_state.selected_suggestion_index = Some(0); // Select first suggestion
|
||||||
register_state.in_suggestion_mode = true;
|
return Ok("Suggestions shown".to_string());
|
||||||
register_state.selected_suggestion_index = Some(0);
|
} else {
|
||||||
return Ok("Suggestions shown".to_string());
|
return Ok("No suggestions available".to_string());
|
||||||
} else {
|
|
||||||
return Ok("No suggestions available".to_string());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// --- End Special Handling ---
|
// --- End Special Handling ---
|
||||||
|
|||||||
Reference in New Issue
Block a user