working autocomplete, need more fixes soon
This commit is contained in:
@@ -42,6 +42,13 @@ pub struct AddLogicState {
|
||||
pub show_target_column_suggestions: bool,
|
||||
pub selected_target_column_suggestion_index: Option<usize>,
|
||||
pub in_target_column_suggestion_mode: bool,
|
||||
|
||||
// Script Editor Autocomplete
|
||||
pub script_editor_autocomplete_active: bool,
|
||||
pub script_editor_suggestions: Vec<String>,
|
||||
pub script_editor_selected_suggestion_index: Option<usize>,
|
||||
pub script_editor_trigger_position: Option<(usize, usize)>, // (line, column)
|
||||
pub script_editor_filter_text: String,
|
||||
}
|
||||
|
||||
impl AddLogicState {
|
||||
@@ -69,6 +76,13 @@ impl AddLogicState {
|
||||
show_target_column_suggestions: false,
|
||||
selected_target_column_suggestion_index: None,
|
||||
in_target_column_suggestion_mode: false,
|
||||
|
||||
// Script Editor Autocomplete initialization
|
||||
script_editor_autocomplete_active: false,
|
||||
script_editor_suggestions: Vec::new(),
|
||||
script_editor_selected_suggestion_index: None,
|
||||
script_editor_trigger_position: None,
|
||||
script_editor_filter_text: String::new(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,6 +128,46 @@ impl AddLogicState {
|
||||
self.selected_target_column_suggestion_index = None;
|
||||
}
|
||||
}
|
||||
|
||||
/// Updates script editor suggestions based on current filter text
|
||||
pub fn update_script_editor_suggestions(&mut self) {
|
||||
let hardcoded_suggestions = vec![
|
||||
"sql".to_string(),
|
||||
"tablename".to_string(),
|
||||
"table column".to_string()
|
||||
];
|
||||
|
||||
if self.script_editor_filter_text.is_empty() {
|
||||
self.script_editor_suggestions = hardcoded_suggestions;
|
||||
} else {
|
||||
let filter_lower = self.script_editor_filter_text.to_lowercase();
|
||||
self.script_editor_suggestions = hardcoded_suggestions
|
||||
.into_iter()
|
||||
.filter(|suggestion| suggestion.to_lowercase().contains(&filter_lower))
|
||||
.collect();
|
||||
}
|
||||
|
||||
// Update selection index
|
||||
if self.script_editor_suggestions.is_empty() {
|
||||
self.script_editor_selected_suggestion_index = None;
|
||||
self.script_editor_autocomplete_active = false;
|
||||
} else if let Some(selected_idx) = self.script_editor_selected_suggestion_index {
|
||||
if selected_idx >= self.script_editor_suggestions.len() {
|
||||
self.script_editor_selected_suggestion_index = Some(0);
|
||||
}
|
||||
} else {
|
||||
self.script_editor_selected_suggestion_index = Some(0);
|
||||
}
|
||||
}
|
||||
|
||||
/// Deactivates script editor autocomplete and clears related state
|
||||
pub fn deactivate_script_editor_autocomplete(&mut self) {
|
||||
self.script_editor_autocomplete_active = false;
|
||||
self.script_editor_suggestions.clear();
|
||||
self.script_editor_selected_suggestion_index = None;
|
||||
self.script_editor_trigger_position = None;
|
||||
self.script_editor_filter_text.clear();
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for AddLogicState {
|
||||
|
||||
Reference in New Issue
Block a user