Skip to content

Commit

Permalink
fix(language-core): define custom block code ID with lower case
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Jun 26, 2024
1 parent 98f4fb3 commit 70b5d86
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions packages/language-core/lib/plugins/vue-sfc-customblocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ const plugin: VueLanguagePlugin = () => {

getEmbeddedCodes(_fileName, sfc) {
return sfc.customBlocks.map((customBlock, i) => ({
id: 'customBlock_' + i,
id: 'custom_block_' + i,
lang: customBlock.lang,
}));
},

resolveEmbeddedCode(_fileName, sfc, embeddedFile) {
if (embeddedFile.id.startsWith('customBlock_')) {
const index = parseInt(embeddedFile.id.slice('customBlock_'.length));
if (embeddedFile.id.startsWith('custom_block_')) {
const index = parseInt(embeddedFile.id.slice('custom_block_'.length));
const customBlock = sfc.customBlocks[index];

embeddedFile.content.push([
Expand Down
6 changes: 3 additions & 3 deletions packages/language-core/lib/virtualFile/computedSfc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function computedSfc(
for (const plugin of plugins) {
const ast = plugin.compileSFCScript?.(base.lang, base.content);
if (ast) {
return ast;;
return ast;
}
}
return ts.createSourceFile(fileName + '.' + base.lang, '', 99 satisfies ts.ScriptTarget.Latest);
Expand Down Expand Up @@ -76,7 +76,7 @@ export function computedSfc(
for (const plugin of plugins) {
const ast = plugin.compileSFCScript?.(base.lang, base.content);
if (ast) {
return ast;;
return ast;
}
}
return ts.createSourceFile(fileName + '.' + base.lang, '', 99 satisfies ts.ScriptTarget.Latest);
Expand Down Expand Up @@ -128,7 +128,7 @@ export function computedSfc(
const customBlocks = computedArray(
computed(() => parsed()?.descriptor.customBlocks ?? []),
(block, i) => {
const base = computedSfcBlock('customBlock_' + i, 'txt', block);
const base = computedSfcBlock('custom_block_' + i, 'txt', block);
const type = computed(() => block().type);
return computed<Sfc['customBlocks'][number]>(() => mergeObject(base, {
get type() { return type(); },
Expand Down

0 comments on commit 70b5d86

Please sign in to comment.