Skip to content

Commit

Permalink
fix: goto definition not working with mapping failed edge cases
Browse files Browse the repository at this point in the history
close #1048, close #435
  • Loading branch information
johnsoncodehk committed Mar 20, 2022
1 parent 924f1e2 commit 96a5872
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
17 changes: 17 additions & 0 deletions packages/vue-code-gen/src/generators/script.ts
Expand Up @@ -100,6 +100,23 @@ export function generate(
);
}

// fix https://github.com/johnsoncodehk/volar/issues/1048, https://github.com/johnsoncodehk/volar/issues/435
codeGen.addMapping2({
data: {
vueTag: 'sfc',
capabilities: {},
},
mode: SourceMaps.Mode.Expand,
mappedRange: {
start: 0,
end: codeGen.getText().length,
},
sourceRange: {
start: 0,
end: 0,
},
});

return {
codeGen,
teleports,
Expand Down
4 changes: 0 additions & 4 deletions packages/vue-typescript/src/use/useSfcScriptGen.ts
Expand Up @@ -59,12 +59,8 @@ export function useSfcScriptGen<T extends 'template' | 'script'>(
});
const file = computed(() => {

let _fileName: string | undefined;

if (lsType === 'script') {

_fileName = fileName + '.' + lang.value

const file: EmbeddedFile = {
lsType,
fileName: fileName + '.' + lang.value,
Expand Down

0 comments on commit 96a5872

Please sign in to comment.