Skip to content

Commit

Permalink
Fix autocomplete suggestions for lowercase methods and other related …
Browse files Browse the repository at this point in the history
…bug (#121033)

* Fix autocomplete suggestions for lowercase methods and another related bug

Co-authored-by: Muhammad Ibragimov <[email protected]>
  • Loading branch information
mibragimov and Muhammad Ibragimov authored Dec 14, 2021
1 parent 7176dd5 commit bd01469
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/plugins/console/public/lib/autocomplete/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bd01469

Please sign in to comment.