fixed example, now working everything properly well
This commit is contained in:
@@ -19,7 +19,7 @@ pub struct EditorState {
|
||||
|
||||
// Selection state (for vim visual mode)
|
||||
pub(crate) selection: SelectionState,
|
||||
|
||||
|
||||
// Validation state (only available with validation feature)
|
||||
#[cfg(feature = "validation")]
|
||||
pub(crate) validation: crate::validation::ValidationState,
|
||||
@@ -114,7 +114,7 @@ impl EditorState {
|
||||
pub fn selection_state(&self) -> &SelectionState {
|
||||
&self.selection
|
||||
}
|
||||
|
||||
|
||||
/// Get validation state (for user's business logic)
|
||||
/// Only available when the 'validation' feature is enabled
|
||||
#[cfg(feature = "validation")]
|
||||
@@ -134,7 +134,12 @@ impl EditorState {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn set_cursor(&mut self, position: usize, max_position: usize, for_edit_mode: bool) {
|
||||
pub(crate) fn set_cursor(
|
||||
&mut self,
|
||||
position: usize,
|
||||
max_position: usize,
|
||||
for_edit_mode: bool,
|
||||
) {
|
||||
if for_edit_mode {
|
||||
// Edit mode: can go past end for insertion
|
||||
self.cursor_pos = position.min(max_position);
|
||||
@@ -145,6 +150,7 @@ impl EditorState {
|
||||
self.ideal_cursor_column = self.cursor_pos;
|
||||
}
|
||||
|
||||
/// Legacy internal activation (still used internally if needed)
|
||||
pub(crate) fn activate_suggestions(&mut self, field_index: usize) {
|
||||
self.suggestions.is_active = true;
|
||||
self.suggestions.is_loading = true;
|
||||
@@ -153,6 +159,7 @@ impl EditorState {
|
||||
self.suggestions.completion_text = None;
|
||||
}
|
||||
|
||||
/// Legacy internal deactivation
|
||||
pub(crate) fn deactivate_suggestions(&mut self) {
|
||||
self.suggestions.is_active = false;
|
||||
self.suggestions.is_loading = false;
|
||||
@@ -160,6 +167,24 @@ impl EditorState {
|
||||
self.suggestions.selected_index = None;
|
||||
self.suggestions.completion_text = None;
|
||||
}
|
||||
|
||||
/// Explicitly open suggestions — should only be called on Tab
|
||||
pub(crate) fn open_suggestions(&mut self, field_index: usize) {
|
||||
self.suggestions.is_active = true;
|
||||
self.suggestions.is_loading = true;
|
||||
self.suggestions.active_field = Some(field_index);
|
||||
self.suggestions.selected_index = None;
|
||||
self.suggestions.completion_text = None;
|
||||
}
|
||||
|
||||
/// Explicitly close suggestions — should be called on Esc or field change
|
||||
pub(crate) fn close_suggestions(&mut self) {
|
||||
self.suggestions.is_active = false;
|
||||
self.suggestions.is_loading = false;
|
||||
self.suggestions.active_field = None;
|
||||
self.suggestions.selected_index = None;
|
||||
self.suggestions.completion_text = None;
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for EditorState {
|
||||
|
||||
@@ -152,6 +152,22 @@ impl<D: DataProvider> FormEditor<D> {
|
||||
&self.ui_state
|
||||
}
|
||||
|
||||
/// Mutable access to UI state for internal crate use only.
|
||||
pub(crate) fn ui_state_mut(&mut self) -> &mut EditorState {
|
||||
&mut self.ui_state
|
||||
}
|
||||
|
||||
/// Open the suggestions UI for `field_index` (UI-only; does not fetch).
|
||||
pub fn open_suggestions(&mut self, field_index: usize) {
|
||||
self.ui_state.open_suggestions(field_index);
|
||||
}
|
||||
|
||||
/// Close suggestions UI and clear the current suggestion results.
|
||||
pub fn close_suggestions(&mut self) {
|
||||
self.ui_state.close_suggestions();
|
||||
self.suggestions.clear();
|
||||
}
|
||||
|
||||
/// Set external validation state for a field (Feature 5)
|
||||
#[cfg(feature = "validation")]
|
||||
pub fn set_external_validation(
|
||||
|
||||
Reference in New Issue
Block a user