From bd01469dc8015f9b94c61972e53de077b4868c56 Mon Sep 17 00:00:00 2001 From: Muhammad Ibragimov <53621505+mibragimov@users.noreply.github.com> Date: Tue, 14 Dec 2021 14:47:59 +0500 Subject: [PATCH] Fix autocomplete suggestions for lowercase methods and other related bug (#121033) * Fix autocomplete suggestions for lowercase methods and another related bug Co-authored-by: Muhammad Ibragimov --- .../console/public/lib/autocomplete/autocomplete.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/plugins/console/public/lib/autocomplete/autocomplete.ts b/src/plugins/console/public/lib/autocomplete/autocomplete.ts index d89a9f3d2e5e2..a85e53d44d1a3 100644 --- a/src/plugins/console/public/lib/autocomplete/autocomplete.ts +++ b/src/plugins/console/public/lib/autocomplete/autocomplete.ts @@ -802,7 +802,7 @@ export default function ({ function addPathAutoCompleteSetToContext(context: AutoCompleteContext, pos: Position) { const ret = getCurrentMethodAndTokenPaths(editor, pos, parser); - context.method = ret.method; + context.method = ret.method?.toUpperCase(); context.token = ret.token; context.otherTokenValues = ret.otherTokenValues; context.urlTokenPath = ret.urlTokenPath; @@ -929,9 +929,12 @@ export default function ({ return; // wait for the next typing. } + // if the column or the line number have not changed for the last token and + // user did not provided a new value, then we should not show autocomplete + // this guards against triggering autocomplete when clicking around the editor if ( - lastEvaluatedToken.position.column !== currentToken.position.column || - lastEvaluatedToken.position.lineNumber !== currentToken.position.lineNumber || + (lastEvaluatedToken.position.column !== currentToken.position.column || + lastEvaluatedToken.position.lineNumber !== currentToken.position.lineNumber) && lastEvaluatedToken.value === currentToken.value ) { // not on the same place or nothing changed, cache and wait for the next time