Skip to content

Commit

Permalink
fix: support suggestions in interpolation in class selector
Browse files Browse the repository at this point in the history
  • Loading branch information
wkillerud committed Jul 29, 2024
1 parent c7a9342 commit 58b360d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,28 @@ test("should suggest symbol from a different document via @use when in string in
const { items } = await ls.doComplete(two, Position.create(1, 29));
assert.ok(items.find((annotation) => annotation.label === "$primary"));
});

test("should suggest symbols when interpolation is part of CSS selector", async () => {
ls.configure({
completionSettings: {
suggestFromUseOnly: true,
},
});

const one = fileSystemProvider.createDocument("$selector: 'test';", {
uri: "one.scss",
});
const two = fileSystemProvider.createDocument(
['@use "./one";', ".#{one.} {}"],
{
uri: "two.scss",
},
);

// emulate scanner of language service which adds workspace documents to the cache
ls.parseStylesheet(one);
ls.parseStylesheet(two);

const { items } = await ls.doComplete(two, Position.create(1, 7));
assert.ok(items.find((annotation) => annotation.label === "$selector"));
});
2 changes: 1 addition & 1 deletion packages/language-services/src/features/do-complete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ export class DoComplete extends LanguageFeature {
: currentWord.substring(
// Skip #{ if this is interpolation
isInterpolation ? currentWord.indexOf("{") + 1 : 0,
currentWord.indexOf("."),
currentWord.indexOf(".", currentWord.indexOf("{") + 1),
);

const isPropertyValue = rePropertyValue.test(lineBeforePosition);
Expand Down

0 comments on commit 58b360d

Please sign in to comment.