Rationalise and optimize autocomplete. Closes #3149

This commit is contained in:
kaidaguerre
2023-02-24 15:31:47 +00:00
committed by GitHub
parent d98df11198
commit 718718d053
4 changed files with 94 additions and 112 deletions

View File

@@ -7,9 +7,8 @@ import (
)
type queryCompletionInfo struct {
Table string
EditingTable bool
EditingColumn bool
Table string
EditingTable bool
}
func getQueryInfo(text string) *queryCompletionInfo {
@@ -17,9 +16,8 @@ func getQueryInfo(text string) *queryCompletionInfo {
prevWord := getPreviousWord(text)
return &queryCompletionInfo{
Table: table,
EditingTable: isEditingTable(prevWord),
EditingColumn: isEditingColumn(prevWord, table),
Table: table,
EditingTable: isEditingTable(prevWord),
}
}
@@ -28,11 +26,6 @@ func isEditingTable(prevWord string) bool {
return editingTable
}
func isEditingColumn(prevWord string, table string) bool {
var editingColumn = prevWord == "where" || prevWord == "and" || prevWord == "or" && table != ""
return editingColumn
}
func getTable(text string) string {
// split on space and remove empty results - they occur if there is a double space
split := helpers.RemoveFromStringSlice(strings.Split(text, " "), "")