Skip to content

Commit

Permalink
fix: goto definition not working for alias path
Browse files Browse the repository at this point in the history
close #728
  • Loading branch information
johnsoncodehk committed Nov 28, 2021
1 parent 7489313 commit 2fb92ea
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
17 changes: 17 additions & 0 deletions packages/vscode-vue-languageservice/src/services/definition.ts
Expand Up @@ -92,6 +92,23 @@ export function register({ sourceFiles, getCssLs, getTsLs }: ApiLanguageServiceC
originSelectionRange,
});
}
else {
// fix https://github.com/johnsoncodehk/volar/issues/728
const targetSourceFile = sourceFiles.getSourceFileByTsUri(tsLoc.lsType, tsLoc_2.targetUri);
if (targetSourceFile) {
const targetDocument = targetSourceFile.getTextDocument();
const targetRange = {
start: targetDocument.positionAt(0),
end: targetDocument.positionAt(targetDocument.getText().length),
};
vueResult.push({
targetUri: targetSourceFile.uri,
targetRange: targetRange,
targetSelectionRange: targetRange,
originSelectionRange,
});
}
}
}

function withTeleports(uri: string, position: vscode.Position, isOriginal: boolean) {
Expand Down
12 changes: 0 additions & 12 deletions packages/vue-code-gen/src/generators/script.ts
Expand Up @@ -27,7 +27,6 @@ export function generate(
const codeGen = createCodeGen<TsMappingData>();
const teleports: SourceMaps.Mapping<TeleportMappingData>[] = [];
const shouldAddExportDefault = lsType === 'script' && !!scriptSetup;
const overlapMapRanges: SourceMaps.Range[] = [];
const usedTypes = {
DefinePropsToOptions: false,
mergePropDefaults: false,
Expand Down Expand Up @@ -140,12 +139,6 @@ export function generate(
);
codeGen.addText(`;\n`);
codeGen.addText(`export { default } from '${src}';\n`);

overlapMapRanges.push({
start: 0,
end: codeGen.getText().length
});

}
function writeScript() {
if (!script)
Expand Down Expand Up @@ -216,12 +209,7 @@ export function generate(
}
function writeExportComponent() {
if (shouldAddExportDefault) {
const start = codeGen.getText().length;
codeGen.addText(`export default (await import('${vueLibName}')).defineComponent({\n`);
overlapMapRanges.push({
start,
end: codeGen.getText().length,
});
}
else {
codeGen.addText(`\n`);
Expand Down

0 comments on commit 2fb92ea

Please sign in to comment.