From efd0be6a1ac51c8b7c3f247dab965d2e727db93e Mon Sep 17 00:00:00 2001 From: sergeyteleshev Date: Mon, 30 Dec 2024 11:41:30 +0100 Subject: [PATCH] Cb 5448 sql assist doesnt work after alias with enabled use long object names (#3140) * CB-5448 adds replacementOffset logic to autocomplete so we have table long names setting * CB-5448 cleanup * CB-5448 cleanup * CB-5448 pr fixes --------- Co-authored-by: Evgenia <139753579+EvgeniaBzzz@users.noreply.github.com> --- .../src/SQLEditor/useSqlDialectAutocompletion.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/webapp/packages/plugin-sql-editor-new/src/SQLEditor/useSqlDialectAutocompletion.ts b/webapp/packages/plugin-sql-editor-new/src/SQLEditor/useSqlDialectAutocompletion.ts index 36ef3c6c4e..b210a87a26 100644 --- a/webapp/packages/plugin-sql-editor-new/src/SQLEditor/useSqlDialectAutocompletion.ts +++ b/webapp/packages/plugin-sql-editor-new/src/SQLEditor/useSqlDialectAutocompletion.ts @@ -24,7 +24,7 @@ const CLOSE_CHARACTERS = /[\s()[\]{};:>,=\\*]/; const COMPLETION_WORD = /[\w*]*/; export function useSqlDialectAutocompletion(data: ISQLEditorData): [Compartment, Extension] { - const { closeCompletion, useEditorAutocompletion } = useComplexLoader(codemirrorComplexLoader); + const { closeCompletion, useEditorAutocompletion, insertCompletionText } = useComplexLoader(codemirrorComplexLoader); const localizationService = useService(LocalizationService); const optionsRef = useObjectRef({ data }); @@ -56,7 +56,9 @@ export function useSqlDialectAutocompletion(data: ISQLEditorData): [Compartment, return [ ...filteredProposals.map(proposal => ({ label: proposal.displayString, - apply: proposal.replacementString, + apply: (view, completion, from, to) => { + view.dispatch(insertCompletionText(view.state, proposal.replacementString, proposal.replacementOffset, to)); + }, boost: proposal.score, icon: proposal.icon, })),