-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: invoke only completers who have matching trigger characters #5274
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -666,8 +666,14 @@ class CompletionProvider { | |
|
||
var matches = []; | ||
this.completers = editor.completers; | ||
var total = editor.completers.length; | ||
editor.completers.forEach(function(completer, i) { | ||
var matchingCompleters = util.getCompletersMatchingTriggerCharacter(editor); | ||
// if there are no matches or there is a prefix, and the prefix is longer than the threshold, | ||
// then use all completers | ||
if (matchingCompleters.length === 0 || (prefix && prefix.length >= editor.$liveAutocompletionThreshold)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there is no completer registered for trigger char There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no, autocomplete won't be triggered at all if there is no prefix (word characters A-Za-z) or trigger char does not match any of the completers, see https://github.com/InspiredGuy/ace/blob/invoke-only-matching-completers-for-trigger-chars/src/ext/language_tools.js#L160 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah right, ty |
||
matchingCompleters = editor.completers; | ||
} | ||
var total = matchingCompleters.length; | ||
matchingCompleters.forEach(function(completer, i) { | ||
completer.getCompletions(editor, session, pos, prefix, function(err, results) { | ||
if (!err && results) | ||
matches = matches.concat(results); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens here if there is a completer with the trigger character
a
, would only the completer with the trigger character get triggered or would all completers still get triggered (as they should given that the user is typing a normal letter)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good question. the autocomplete is triggered when there is a trigger character matching at least one completer or there is a text prefix with non-zero length. string
a
would fall into prefix even if it's a trigger character, but we don't check for it here. I will update implementation to use all completers if there is a prefix.