better autocomplete
This commit is contained in:
@@ -135,16 +135,17 @@ impl AddLogicState {
|
||||
pub fn update_script_editor_suggestions(&mut self) {
|
||||
let mut suggestions = vec!["sql".to_string()];
|
||||
|
||||
// Add actual table name if available (current table)
|
||||
if let Some(ref table_name) = self.selected_table_name {
|
||||
suggestions.push(table_name.clone());
|
||||
if self.selected_table_name.is_some() {
|
||||
suggestions.extend(self.table_columns_for_suggestions.clone());
|
||||
}
|
||||
|
||||
// Add column names from the current table
|
||||
suggestions.extend(self.table_columns_for_suggestions.clone());
|
||||
|
||||
// Add table names from SAME profile only
|
||||
suggestions.extend(self.same_profile_table_names.clone());
|
||||
let current_selected_table_name = self.selected_table_name.as_deref();
|
||||
suggestions.extend(
|
||||
self.same_profile_table_names
|
||||
.iter()
|
||||
.filter(|tn| Some(tn.as_str()) != current_selected_table_name)
|
||||
.cloned()
|
||||
);
|
||||
|
||||
if self.script_editor_filter_text.is_empty() {
|
||||
self.script_editor_suggestions = suggestions;
|
||||
@@ -169,6 +170,18 @@ impl AddLogicState {
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks if a suggestion is a table name (for triggering column autocomplete)
|
||||
pub fn is_table_name_suggestion(&self, suggestion: &str) -> bool {
|
||||
// Not "sql"
|
||||
if suggestion == "sql" {
|
||||
return false;
|
||||
}
|
||||
if self.table_columns_for_suggestions.contains(&suggestion.to_string()) {
|
||||
return false;
|
||||
}
|
||||
self.same_profile_table_names.contains(&suggestion.to_string())
|
||||
}
|
||||
|
||||
/// Sets table columns for autocomplete suggestions
|
||||
pub fn set_table_columns(&mut self, columns: Vec<String>) {
|
||||
self.table_columns_for_suggestions = columns.clone();
|
||||
@@ -187,25 +200,6 @@ impl AddLogicState {
|
||||
self.same_profile_table_names = table_names;
|
||||
}
|
||||
|
||||
/// Checks if a suggestion is a table name (for triggering column autocomplete)
|
||||
pub fn is_table_name_suggestion(&self, suggestion: &str) -> bool {
|
||||
if suggestion == "sql" {
|
||||
return false;
|
||||
}
|
||||
|
||||
if let Some(ref current_table) = self.selected_table_name {
|
||||
if suggestion == current_table {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if self.table_columns_for_suggestions.contains(&suggestion.to_string()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
self.same_profile_table_names.contains(&suggestion.to_string())
|
||||
}
|
||||
|
||||
/// Triggers waiting for column autocomplete for a specific table
|
||||
pub fn trigger_column_autocomplete_for_table(&mut self, table_name: String) {
|
||||
self.script_editor_awaiting_column_autocomplete = Some(table_name);
|
||||
|
||||
Reference in New Issue
Block a user