we are suggesting properly table column names now
This commit is contained in:
@@ -39,6 +39,7 @@ pub struct AppState {
|
||||
pub selected_profile: Option<String>,
|
||||
pub current_mode: AppMode,
|
||||
pub focused_button_index: usize,
|
||||
pub pending_table_structure_fetch: Option<(String, String)>,
|
||||
|
||||
// UI preferences
|
||||
pub ui: UiState,
|
||||
@@ -57,6 +58,7 @@ impl AppState {
|
||||
selected_profile: None,
|
||||
current_mode: AppMode::General,
|
||||
focused_button_index: 0,
|
||||
pending_table_structure_fetch: None,
|
||||
ui: UiState::default(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -131,22 +131,26 @@ impl AddLogicState {
|
||||
|
||||
/// 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()
|
||||
];
|
||||
let mut suggestions = vec!["sql".to_string()];
|
||||
|
||||
// Add actual table name if available
|
||||
if let Some(ref table_name) = self.selected_table_name {
|
||||
suggestions.push(table_name.clone());
|
||||
}
|
||||
|
||||
// Add column names from the table
|
||||
suggestions.extend(self.table_columns_for_suggestions.clone());
|
||||
|
||||
if self.script_editor_filter_text.is_empty() {
|
||||
self.script_editor_suggestions = hardcoded_suggestions;
|
||||
self.script_editor_suggestions = suggestions;
|
||||
} else {
|
||||
let filter_lower = self.script_editor_filter_text.to_lowercase();
|
||||
self.script_editor_suggestions = hardcoded_suggestions
|
||||
self.script_editor_suggestions = 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;
|
||||
@@ -160,6 +164,15 @@ impl AddLogicState {
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets table columns for autocomplete suggestions
|
||||
pub fn set_table_columns(&mut self, columns: Vec<String>) {
|
||||
self.table_columns_for_suggestions = columns.clone();
|
||||
// Also update target column suggestions for the input field
|
||||
if !columns.is_empty() {
|
||||
self.update_target_column_suggestions();
|
||||
}
|
||||
}
|
||||
|
||||
/// Deactivates script editor autocomplete and clears related state
|
||||
pub fn deactivate_script_editor_autocomplete(&mut self) {
|
||||
self.script_editor_autocomplete_active = false;
|
||||
|
||||
Reference in New Issue
Block a user