-
Notifications
You must be signed in to change notification settings - Fork 48
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: Prevent excessive autocompletion in template JS files #490
Conversation
We shouldn't be checking for curly braces yet in JS files, so this fix ignores them entirely until we explictly want to check for something. Updated tests to explictly test JS files as well. vscode #3902
@@ -141,7 +141,7 @@ export default class Server { | |||
if (await this.context.isLWCTemplate(doc)) { | |||
this.auraDataProvider.activated = false; // provide completions for lwc components in an Aura template | |||
this.lwcDataProvider.activated = true; | |||
if (params.context?.triggerCharacter === '{') { | |||
if (this.shouldProvideBindingsInHTML(params)) { |
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.
Open to better naming here and for the shouldCompleteJavascript
below, but I definitely didn't think the previous statement was clear on why we were matching on specific characters.
}, | ||
context: { | ||
triggerCharacter: '{', | ||
triggerKind: 2, |
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.
total nit: do we have an enum for triggerKind?
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.
So this comes from the vscode-language-server-protocol, where it looks like CompletionTriggerKind is declared as a type. Not sure if we can/want to import that here.
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.
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.
Cool beans, just added!
isIncomplete: false, | ||
items: customTags, | ||
}; | ||
} |
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.
so previously we always returned here, but we only return when it passes shouldCompleteJavascript. Should we move the inner if into the above condition, or should we be returning with no results when no matching tag was found?
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.
Ah, I see what you mean. I think an early empty return like what we have for the last else would be a good change here.
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.
Added!
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.
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 work 👍
What does this PR do?
What issues does this PR fix or reference?
VS Code #3902. @W-10832653@