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

fix(language-core): inlay hints for <component :is> and <slot :name> #4661

Merged
merged 12 commits into from
Oct 23, 2024
Prev Previous commit
Next Next commit
Update element.ts
  • Loading branch information
johnsoncodehk committed Oct 23, 2024
commit c75b33babc4c601c7c9746b1bf1807484bdcce06
8 changes: 3 additions & 5 deletions packages/language-core/lib/codegen/template/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export function* generateComponent(
exp: CompilerDOM.ElementNode | CompilerDOM.ExpressionNode;
tag: string;
offsets: [number, number | undefined];
isComponentIsShorthand?: boolean;
} | undefined;

if (isComponentTag) {
Expand All @@ -63,11 +62,13 @@ export function* generateComponent(
&& prop.arg?.loc.source === 'is'
&& prop.exp?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION
) {
if (prop.arg.loc.end.offset === prop.exp.loc.end.offset) {
ctx.inlayHints.push(createVBindShorthandInlayHintInfo(prop.exp.loc, 'is'));
}
dynamicTagInfo = {
exp: prop.exp,
tag: prop.exp.content,
offsets: [prop.exp.loc.start.offset, undefined],
isComponentIsShorthand: prop.arg.loc.end.offset === prop.exp.loc.end.offset
};
props = props.filter(p => p !== prop);
break;
Expand Down Expand Up @@ -114,9 +115,6 @@ export function* generateComponent(
yield `]${endOfLine}`;
}
else if (dynamicTagInfo) {
if (dynamicTagInfo.isComponentIsShorthand) {
ctx.inlayHints.push(createVBindShorthandInlayHintInfo(dynamicTagInfo.exp.loc, 'is'));
}
yield `const ${var_originalComponent} = (`;
yield* generateInterpolation(
options,
Expand Down