tablenames added properly well

This commit is contained in:
filipriec
2025-05-26 19:51:48 +02:00
parent f3cd921c76
commit bf2726c151
3 changed files with 75 additions and 55 deletions

View File

@@ -48,6 +48,7 @@ pub struct AddLogicState {
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 all_table_names: Vec<String>,
pub script_editor_filter_text: String,
}
@@ -82,6 +83,7 @@ impl AddLogicState {
script_editor_suggestions: Vec::new(),
script_editor_selected_suggestion_index: None,
script_editor_trigger_position: None,
all_table_names: Vec::new(),
script_editor_filter_text: String::new(),
}
}
@@ -132,15 +134,18 @@ impl AddLogicState {
/// Updates script editor suggestions based on current filter text
pub fn update_script_editor_suggestions(&mut self) {
let mut suggestions = vec!["sql".to_string()];
// Add actual table name if available
// Add actual table name if available (current table)
if let Some(ref table_name) = self.selected_table_name {
suggestions.push(table_name.clone());
}
// Add column names from the table
// Add column names from the current table
suggestions.extend(self.table_columns_for_suggestions.clone());
// Add all table names from all profiles
suggestions.extend(self.all_table_names.clone());
if self.script_editor_filter_text.is_empty() {
self.script_editor_suggestions = suggestions;
} else {
@@ -173,6 +178,11 @@ impl AddLogicState {
}
}
/// Sets all available table names for autocomplete suggestions
pub fn set_all_table_names(&mut self, table_names: Vec<String>) {
self.all_table_names = table_names;
}
/// Deactivates script editor autocomplete and clears related state
pub fn deactivate_script_editor_autocomplete(&mut self) {
self.script_editor_autocomplete_active = false;