diff --git a/frontend/src/AppBuilder/CodeEditor/autocompleteExtensionConfig.js b/frontend/src/AppBuilder/CodeEditor/autocompleteExtensionConfig.js index 23647e1420..17780cdf85 100644 --- a/frontend/src/AppBuilder/CodeEditor/autocompleteExtensionConfig.js +++ b/frontend/src/AppBuilder/CodeEditor/autocompleteExtensionConfig.js @@ -162,13 +162,11 @@ export const generateHints = (hints, totalReferences = 1, input, searchText) => changes: pickedCompletionConfig, }; - const actualInput = removeNestedDoubleCurlyBraces(doc.toString()); - - if (actualInput.length === 0) { - dispatchConfig.selection = { - anchor: anchorSelection, - }; - } + dispatchConfig.selection = { + anchor: + pickedCompletionConfig.from + + (completion.type === 'js_methods' ? completion.label.length - 1 : completion.label.length), + }; view.dispatch(dispatchConfig); }, @@ -331,11 +329,14 @@ export const getSuggestionsForMultiLine = (context, allHints, hints = {}, lang, break; } } - dispacthConfig.selection = { - anchor: pickedCompletionConfig.from + completion.label.length - 1, - }; } + dispacthConfig.selection = { + anchor: + pickedCompletionConfig.from + + (completion.type === 'js_methods' ? completion.label.length - 1 : completion.label.length), + }; + view.dispatch(dispacthConfig); }; return hint;