Skip to content
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

do not suggest lang when editing attributes #469

Conversation

tanhauhau
Copy link
Member

Before

Screenshot 2020-08-21 at 8 25 22 AM

After

Screenshot 2020-08-21 at 8 24 51 AM

@tanhauhau
Copy link
Member Author

how do i add test for this?

@jasonlyu123
Copy link
Member

You can have a test similar to this one

setup('<div sty') and filter the return list see if lang completion exists

@dummdidumm
Copy link
Member

Note: You need to merge the changes from master in and do yarn install again, yarn.lock and tests have changed.

@dummdidumm
Copy link
Member

I noticed there is an easier (and possibly more performant) way to fix this:

The completion for tags has CompletionItemKind.Property, while the completion for attributes has CompletionItemKind.Value. So we can just enhance the filter like this

const styleScriptTemplateCompletions = completions.filter((completion) =>
     completion.kind === CompletionItemKind.Property && ['template', 'style', 'script'].includes(completion.label),
;

@tanhauhau tanhauhau force-pushed the tanhauhau/only-suggest-lang-when-editing-tag branch from e71d408 to 14ed766 Compare August 22, 2020 17:37
@tanhauhau
Copy link
Member Author

ok , updated the branch and added test case

Copy link
Member

@dummdidumm dummdidumm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

const styleScriptTemplateCompletions = completions.filter(
(completion) =>
completion.kind === CompletionItemKind.Property &&
this.styleScriptTemplate.has(completion.label),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a great optimization!

@dummdidumm dummdidumm merged commit afcd008 into sveltejs:master Aug 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants