diff --git a/packages/language-services/src/features/__tests__/do-complete-interpolation.test.ts b/packages/language-services/src/features/__tests__/do-complete-interpolation.test.ts index 7404eef5..6db38e63 100644 --- a/packages/language-services/src/features/__tests__/do-complete-interpolation.test.ts +++ b/packages/language-services/src/features/__tests__/do-complete-interpolation.test.ts @@ -116,3 +116,32 @@ test("should suggest symbols when interpolation is part of CSS selector", async const { items } = await ls.doComplete(two, Position.create(1, 7)); assert.ok(items.find((annotation) => annotation.label === "$selector")); }); + +test("should suggest variables and functions as function parameters in string interpolation ", async () => { + ls.configure({ + completionSettings: { + suggestFromUseOnly: true, + }, + }); + + const one = fileSystemProvider.createDocument( + ["$primary: limegreen;", "@function compare($a: 1, $b) {}"], + { + uri: "one.scss", + }, + ); + const two = fileSystemProvider.createDocument( + ['@use "./one";', '$test: "#{one.compare(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, 26)); + assert.ok(items.find((annotation) => annotation.label === "$primary")); + assert.ok(items.find((annotation) => annotation.label === "compare")); +}); diff --git a/packages/language-services/src/features/do-complete.ts b/packages/language-services/src/features/do-complete.ts index aca429fd..027c3ad7 100644 --- a/packages/language-services/src/features/do-complete.ts +++ b/packages/language-services/src/features/do-complete.ts @@ -408,7 +408,8 @@ export class DoComplete extends LanguageFeature { }; } - const isInterpolation = currentWord.includes("#{"); + const isInterpolation = + currentWord.includes("#{") || lineBeforePosition.includes("#{"); const context: CompletionContext = { currentWord,