Skip to content

Commit ebc90c2

Browse files
atscottthePunderWoman
authored andcommitted
feat(language-server): Add completions and hover info for inline styles
This adds completions for inline styles, using the SCSS language service resolves #65489
1 parent 573aade commit ebc90c2

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

vscode-ng-language-service/server/src/session.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1403,7 +1403,24 @@ export class Session {
14031403
options,
14041404
);
14051405
if (!completions) {
1406-
return null;
1406+
const sf = this.getDefaultProjectForScriptInfo(scriptInfo)?.getSourceFile(scriptInfo.path);
1407+
if (!sf) {
1408+
return null;
1409+
}
1410+
const node = getTokenAtPosition(sf, offset);
1411+
if (!isInlineStyleNode(node)) {
1412+
return null;
1413+
}
1414+
const virtualScssDocContents = getSCSSVirtualContent(sf);
1415+
const virtualScssDoc = TextDocument.create(
1416+
params.textDocument.uri.toString(),
1417+
'scss',
1418+
0,
1419+
virtualScssDocContents,
1420+
);
1421+
const stylesheet = scssLS.parseStylesheet(virtualScssDoc);
1422+
const scssCompletions = scssLS.doComplete(virtualScssDoc, params.position, stylesheet);
1423+
return scssCompletions.items;
14071424
}
14081425
return completions.entries.map((e) =>
14091426
tsCompletionEntryToLspCompletionItem(e, params.position, scriptInfo),

0 commit comments

Comments
 (0)