@@ -8,7 +8,7 @@ import { basename, posix } from 'path';
8
8
import * as vscode from 'vscode' ;
9
9
import { Utils } from 'vscode-uri' ;
10
10
import { coalesce } from '../utils/arrays' ;
11
- import { exists } from '../utils/fs' ;
11
+ import { exists , looksLikeAbsoluteWindowsPath } from '../utils/fs' ;
12
12
13
13
function mapChildren < R > ( node : jsonc . Node | undefined , f : ( x : jsonc . Node ) => R ) : R [ ] {
14
14
return node && node . type === 'array' && node . children
@@ -48,10 +48,6 @@ class TsconfigLinkProvider implements vscode.DocumentLinkProvider {
48
48
}
49
49
50
50
const extendsValue : string = extendsNode . value ;
51
- if ( extendsValue . startsWith ( '/' ) ) {
52
- return undefined ;
53
- }
54
-
55
51
const args : OpenExtendsLinkCommandArgs = {
56
52
resourceUri : { ...document . uri . toJSON ( ) , $mid : undefined } , // Prevent VS Code from trying to transform the uri
57
53
extendsValue : extendsValue
@@ -161,20 +157,24 @@ async function resolveNodeModulesPath(baseDirUri: vscode.Uri, pathCandidates: st
161
157
* @returns Returns undefined in case of lack of result while trying to resolve from node_modules
162
158
*/
163
159
async 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 ) ) {
171
162
return absolutePath ;
172
163
}
173
164
return absolutePath . with ( {
174
165
path : `${ absolutePath . path } .json`
175
166
} ) ;
176
167
}
177
168
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
+
178
178
// Otherwise resolve like a module
179
179
return resolveNodeModulesPath ( baseDirUri , [
180
180
extendsValue ,
0 commit comments