atom/autocomplete-css

Need suggestions for embedded Sass styles

aidistan opened this issue · 3 comments

Current version of autocomplete-css detect whether the scope is a Sass one by using the method hasScope to search the scope array to find one with the exact name source.sass. Such behaviour makes autocompletion broken in many embedding situations.

Take .vue as an example (hedefalk/atom-vue#46), lines between style tags have no suggestions for Sass:

<template>
  <!-- The scope here is [text.html.vue] -->
</template>

<style lang="sass">
  // The scopes here are [text.html.vue, source.sass.embedded.html]
html
  widt// no suggestion
</style>

We could hack this issue by using source.sass as the scope name in text.html.vue. But doing that will violate the scope naming conventions which we respect a lot.

I think we could improve the way of scope detection here by change hasScope to containScope which search the scope array to find any scope starts with source.sass. Any idea?

What do you think about also searching for the *.embedded.html variant? So it would search for source.sass as well as source.sass.embedded.html. Maybe make it a boolean (checkEmbedded) you can pass to the hasScope function.

@50Wliu It's also a good idea. Both meet our need. Shall I start to make this PR?

Sure 👍