@@ -8,7 +8,7 @@ import { basename, posix } from 'path';
88import * as vscode from 'vscode' ;
99import { Utils } from 'vscode-uri' ;
1010import { coalesce } from '../utils/arrays' ;
11- import { exists } from '../utils/fs' ;
11+ import { exists , looksLikeAbsoluteWindowsPath } from '../utils/fs' ;
1212
1313function mapChildren < R > ( node : jsonc . Node | undefined , f : ( x : jsonc . Node ) => R ) : R [ ] {
1414 return node && node . type === 'array' && node . children
@@ -48,10 +48,6 @@ class TsconfigLinkProvider implements vscode.DocumentLinkProvider {
4848 }
4949
5050 const extendsValue : string = extendsNode . value ;
51- if ( extendsValue . startsWith ( '/' ) ) {
52- return undefined ;
53- }
54-
5551 const args : OpenExtendsLinkCommandArgs = {
5652 resourceUri : { ...document . uri . toJSON ( ) , $mid : undefined } , // Prevent VS Code from trying to transform the uri
5753 extendsValue : extendsValue
@@ -161,20 +157,24 @@ async function resolveNodeModulesPath(baseDirUri: vscode.Uri, pathCandidates: st
161157* @returns Returns undefined in case of lack of result while trying to resolve from node_modules
162158*/
163159async function getTsconfigPath ( baseDirUri : vscode . Uri , extendsValue : string ) : Promise < vscode . Uri | undefined > {
164- // Don't take into account a case, where tsconfig might be resolved from the root (see the reference)
165- // e.g. C:/projects/shared-tsconfig/tsconfig.json (note that C: prefix is optional)
166-
167- const isRelativePath = [ './' , '../' ] . some ( str => extendsValue . startsWith ( str ) ) ;
168- if ( isRelativePath ) {
169- const absolutePath = vscode . Uri . joinPath ( baseDirUri , extendsValue ) ;
170- if ( await exists ( absolutePath ) || absolutePath . path . endsWith ( '.json' ) ) {
160+ async function resolve ( absolutePath : vscode . Uri ) : Promise < vscode . Uri > {
161+ if ( absolutePath . path . endsWith ( '.json' ) || await exists ( absolutePath ) ) {
171162 return absolutePath ;
172163 }
173164 return absolutePath . with ( {
174165 path : `${ absolutePath . path } .json`
175166 } ) ;
176167 }
177168
169+ const isRelativePath = [ './' , '../' ] . some ( str => extendsValue . startsWith ( str ) ) ;
170+ if ( isRelativePath ) {
171+ return resolve ( vscode . Uri . joinPath ( baseDirUri , extendsValue ) ) ;
172+ }
173+
174+ if ( extendsValue . startsWith ( '/' ) || looksLikeAbsoluteWindowsPath ( extendsValue ) ) {
175+ return resolve ( vscode . Uri . file ( extendsValue ) ) ;
176+ }
177+
178178 // Otherwise resolve like a module
179179 return resolveNodeModulesPath ( baseDirUri , [
180180 extendsValue ,
0 commit comments