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

Code suggestions in interpolations in a quoted string don't come automatically #190

Open
wkillerud opened this issue Jul 29, 2024 · 7 comments
Labels

Comments

@wkillerud
Copy link
Owner

wkillerud commented Jul 29, 2024

About VS Code
Version: 1.91.1 (Universal)
Commit: f1e16e1e6214d7c44d078b1f0607b2388f29d729
Date: 2024-07-09T22:07:54.982Z
Electron: 29.4.0
ElectronBuildId: 9728852
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Darwin arm64 23.5.0

  • Extension version: 3.1.11
  • Operating system: macOS

Reproducible Case: MenSeb/some-sass-bug@48d7175

Steps to Reproduce:

  1. Open index.scss
  2. On line 6 ($test: "#{test.hello()}") the interpolation should show code completions once you finish typing "#{.

Investigating in #186, it seems like VS Code does not send onCompletion requests even if we last responded with isIncomplete = true set on the result.

@wkillerud wkillerud added the bug Something isn't working label Jul 29, 2024
@wkillerud wkillerud changed the title VS Code doesn't ask for code suggestions inside a quoted string Code suggestions inside a quoted string don't come automatically Jul 29, 2024
@wkillerud wkillerud changed the title Code suggestions inside a quoted string don't come automatically Code suggestions in interpolations in a quoted string don't come automatically Jul 29, 2024
@wkillerud
Copy link
Owner Author

As mentioned in #186 (comment), there are workarounds:

  • Trigger code suggestions manually with Ctrl + Space
  • Skip the quotes

@MenSeb
Copy link
Contributor

MenSeb commented Jul 30, 2024

Ok, I can confirm that without the quotes it shows suggestions and with quotes using crtl + space works.

I may have found something else related to this issue/bug.

If I want to include a mixin from another file with the @include rule it works, for example:

@use './test' as test;

@include test. // shows the existing mixins

But if I want to use a function or variable in a mixin from an @include rule, it won't work, for example:

// _test.scss
@function name() {
    @return 'Some Sass';
}
// _index.scss
@use './test' as test;

// works correctly here, but it only shows existing mixins
// it should show the variable $name and the function name()
@include test.hello(test.name());

This conflict seems to be related to the fact that it only expects mixin since the line includes a @include rule. This raises another issue related to what it shoud display depending on the context in which it is used. For example:

// _index.scss

// work with the ctrl + space, but it shows everything, even mixins?
$test: "#{test.hello()}"; 

// works correctly here, but it shows everything, even mixins?
#{test.selector()} { 
    width: 100%;
}

The repository is up to date with all of this.

@wkillerud
Copy link
Owner Author

Thanks @MenSeb, the bug of variables and functions not being suggested as mixin parameters is fixed in 3.3.0.

works correctly here, but it shows everything, even mixins?

I don't see mixins in my code suggestions there. There are two suggestions for hello, but both of them are for the function (one with, and one without parameters).

@MenSeb
Copy link
Contributor

MenSeb commented Aug 7, 2024

Thanks @wkillerud it works perfectly!

I don't see mixins in my code suggestions there. There are two suggestions for hello, but both of them are for the function (one with, and one without parameters).

My apologies, I may have confused functions with mixins at that moment, I can't reproduce what I pointed out.

@MenSeb
Copy link
Contributor

MenSeb commented Aug 7, 2024

I may have something else to add, I don't think it as a bug, but rather a feature that could be implemented. It is related to code suggestion, would you rather have a new issue for that or should I continue here? (I am updating the repo right now)

It does behave differently in some situation, I don't know if it is related to the extension tho.

The suggestions won't show what was forwarded from a sass package.

// _sass.scss

@use 'sass:meta';

@function is-number($value) {
    @return meta.type-of($value) == number;
}
// _test.scss

@forward 'pkg:sass-true';
@forward 'sass:meta';
@forward './sass';
// index.scss

@use './test' as test;

// The custom logic is forwarded and shows suggestions
@debug test.is-number(10);

// The package pkg:sass-true is forwarded and shows suggestions
@debug test.$catch-errors;

// The package sass:meta is forwarded but it won't shows suggestions
@debug test.type-of('string'); 

The repo is up to date, please let me know if you wish to open a new issue for that.

@wkillerud
Copy link
Owner Author

wkillerud commented Aug 7, 2024

The suggestions won't show what was forwarded from a sass package.

Interesting, I hadn't considered that case 😄 The completions for sass built-ins get added here, but only if they are @used in the current document.

link.target &&
link.type === NodeType.Use &&
link.namespace === namespace
) {
if (link.target.includes("sass:")) {
// Look for matches in built-in namespaces, which do not appear in storage
for (const [builtIn, docs] of Object.entries(sassBuiltInModules)) {
if (builtIn === link.target) {
const items = this.doSassBuiltInCompletion(
document,
context,
docs,
);
return items;
}
}
} else {

I'll take a look at adding support for @forward in this case.

No need for a new issue this time, but if you find something else it would be great if you opened a new issue – easier for me to keep track that way 👍

Edit: fixed in 3.4.0

@MenSeb
Copy link
Contributor

MenSeb commented Aug 7, 2024

I came up with this case while trying to forward "enhanced" sass modules with more utilities added to them haha

It works like a charm, thank you so much for your time and development :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants