Skip to content

Commit

Permalink
fix empty slot name completion [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Nov 27, 2023
1 parent 516eccd commit dabf16a
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions packages/language-core/src/generators/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ export function generate(
)
: [
'.',
['', 'template', slotDir.loc.start.offset, combineEnabled(presetInfos.slotName, { completionItems: false })] satisfies Code,
['', 'template', slotDir.loc.start.offset, { ...presetInfos.slotName, completionItems: false }] satisfies Code,
'default',
['', 'template', slotDir.loc.start.offset + (slotDir.loc.source.startsWith('#') ? '#'.length : slotDir.loc.source.startsWith('v-slot:') ? 'v-slot:'.length : 0), { __combineLastMappping: true }] satisfies Code,
]
Expand Down Expand Up @@ -1045,8 +1045,13 @@ export function generate(
[
'',
'template',
slotDir.loc.start.offset + (slotDir.loc.source.startsWith('#') ? '#'.length : slotDir.loc.source.startsWith('v-slot:') ? 'v-slot:'.length : 0),
{ completionItems: true },
slotDir.loc.start.offset + (
slotDir.loc.source.startsWith('#')
? '#'.length : slotDir.loc.source.startsWith('v-slot:')
? 'v-slot:'.length
: 0
),
withAllDisabled({ completionItems: true }),
],
`'/* empty slot name completion */]\n`,
);
Expand Down Expand Up @@ -1711,13 +1716,13 @@ export function generate(
'__VLS_normalizeSlot(',
['', 'template', node.loc.start.offset, presetInfos.diagnosticOnly],
`${slotsAssignName ?? '__VLS_slots'}[`,
['', 'template', node.loc.start.offset, presetInfos.diagnosticOnly],
['', 'template', node.loc.start.offset, { __combineLastMappping: true }],
slotNameExpNode?.content ?? `('${getSlotName()?.[0] ?? 'default'}' as const)`,
['', 'template', node.loc.end.offset, presetInfos.diagnosticOnly],
['', 'template', node.loc.end.offset, { __combineLastMappping: true }],
']',
['', 'template', node.loc.end.offset, presetInfos.diagnosticOnly],
['', 'template', node.loc.end.offset, { __combineLastMappping: true }],
')?.(',
['', 'template', startTagOffset, presetInfos.diagnosticOnly],
['', 'template', startTagOffset, { __combineLastMappping: true }],
'{\n',
);
}
Expand Down

0 comments on commit dabf16a

Please sign in to comment.