diff --git a/src/app/(main)/query-runner/_components/cql-autocompleter.ts b/src/app/(main)/query-runner/_components/cql-autocompleter.ts index 040d8ae..5bef1a1 100644 --- a/src/app/(main)/query-runner/_components/cql-autocompleter.ts +++ b/src/app/(main)/query-runner/_components/cql-autocompleter.ts @@ -1,15 +1,14 @@ import { ScyllaKeyspace } from "@lambda-group/scylladb"; import { useMonaco } from "@monaco-editor/react"; import KeyspaceDefinitions from "@scylla-studio/app/(main)/keyspace/[keyspace]/_components/keyspace-tables"; -import { getFullQueryAtCursor, getSingleLineQueryAtCursor } from "@scylla-studio/app/(main)/query-runner/_components/utils"; +import { + getFullQueryAtCursor, + getSingleLineQueryAtCursor, +} from "@scylla-studio/app/(main)/query-runner/_components/utils"; import { useCqlFilters } from "@scylla-studio/hooks/use-cql-filters"; import { KeyspaceDefinition } from "@scylla-studio/lib/cql-parser/keyspace-parser"; import { TableDefinition } from "@scylla-studio/lib/cql-parser/table-parser"; -import { - - editor, - languages, -} from "monaco-editor"; +import { editor, languages } from "monaco-editor"; export type MonacoInstance = NonNullable>; @@ -304,14 +303,12 @@ export const cqlCompletionItemProvider = ( monacoInstance: MonacoInstance, editor: editor.IStandaloneCodeEditor, keyspaces?: KeyspaceDefinition[], - keyspacesTables?: TableCompletion[] + keyspacesTables?: TableCompletion[], ): languages.CompletionItem[] => { - - const cursor = getSingleLineQueryAtCursor(editor, monacoInstance); if (!cursor) return getDefaultSuggestions(monacoInstance); - const textUntilPosition = cursor.query.split("\n\n").shift()?.replaceAll(";", "") || ""; - + const textUntilPosition = + cursor.query.split("\n\n").shift()?.replaceAll(";", "") || ""; const useKeyspaceRegex = /USE\s+(\w*)$/i; const fromTableRegex = /FROM\s+(\w*)$/i; @@ -319,10 +316,12 @@ export const cqlCompletionItemProvider = ( const whereColumnRegex = /WHERE\s+(\w*)$/i; // Check if you're typing a keyspace if (useKeyspaceRegex.test(textUntilPosition)) { - - return prepareUseSuggestions(monacoInstance, (keyspaces as any) as KeyspaceDefinition[] || []); + return prepareUseSuggestions( + monacoInstance, + (keyspaces as any as KeyspaceDefinition[]) || [], + ); } else if (fromTableRegex.test(textUntilPosition)) { - return prepareTablesSuggestions(monacoInstance, keyspacesTables || []); + return prepareTablesSuggestions(monacoInstance, keyspacesTables || []); } else if (selectColumnRegex.test(textUntilPosition)) { // TODO: or we display everything related to all tables or we display nothing return getDefaultSuggestions(monacoInstance);