From ea2ad14ddedb29c2a1ffd67b971212da17b1650e Mon Sep 17 00:00:00 2001 From: Vitaliy Mazurenko Date: Mon, 8 Apr 2019 17:58:51 +0300 Subject: [PATCH] fix link navigation to extended config file in tsconfig --- .../src/features/tsconfig.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/extensions/typescript-language-features/src/features/tsconfig.ts b/extensions/typescript-language-features/src/features/tsconfig.ts index a7e89ea133285..2a47c0887bd47 100644 --- a/extensions/typescript-language-features/src/features/tsconfig.ts +++ b/extensions/typescript-language-features/src/features/tsconfig.ts @@ -26,23 +26,30 @@ class TsconfigLinkProvider implements vscode.DocumentLinkProvider { } return [ - this.getExendsLink(document, root), + this.getExtendsLink(document, root), ...this.getFilesLinks(document, root), ...this.getReferencesLinks(document, root) ].filter(x => !!x) as vscode.DocumentLink[]; } - private getExendsLink(document: vscode.TextDocument, root: jsonc.Node): vscode.DocumentLink | undefined { + private getExtendsLink(document: vscode.TextDocument, root: jsonc.Node): vscode.DocumentLink | undefined { const extendsNode = jsonc.findNodeAtLocation(root, ['extends']); if (!this.isPathValue(extendsNode)) { return undefined; } + if (extendsNode.value.startsWith('.')) { + return new vscode.DocumentLink( + this.getRange(document, extendsNode), + vscode.Uri.file(join(dirname(document.uri.fsPath), extendsNode.value + (extendsNode.value.endsWith('.json') ? '' : '.json'))) + ); + } + + const workspaceFolderPath = vscode.workspace.getWorkspaceFolder(document.uri)!.uri.fsPath; return new vscode.DocumentLink( this.getRange(document, extendsNode), - basename(extendsNode.value).match('.json$') - ? this.getFileTarget(document, extendsNode) - : vscode.Uri.file(join(dirname(document.uri.fsPath), extendsNode!.value + '.json'))); + vscode.Uri.file(join(workspaceFolderPath, 'node_modules', extendsNode.value + (extendsNode.value.endsWith('.json') ? '' : '.json'))) + ); } private getFilesLinks(document: vscode.TextDocument, root: jsonc.Node) {