@@ -54,6 +54,7 @@ import {
54
54
getOwnKeys ,
55
55
getPackageJsonTypesVersionsPaths ,
56
56
getPathComponents ,
57
+ getPathsBasePath ,
57
58
getReplacementSpanForContextToken ,
58
59
getResolvePackageJsonExports ,
59
60
getSupportedExtensions ,
@@ -559,7 +560,7 @@ function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile: SourceFile
559
560
const scriptDirectory = getDirectoryPath ( scriptPath ) ;
560
561
const extensionOptions = getExtensionOptions ( compilerOptions , ReferenceKind . ModuleSpecifier , sourceFile , typeChecker , preferences , mode ) ;
561
562
562
- return isPathRelativeToScript ( literalValue ) || ! compilerOptions . baseUrl && ( isRootedDiskPath ( literalValue ) || isUrl ( literalValue ) )
563
+ return isPathRelativeToScript ( literalValue ) || ! compilerOptions . baseUrl && ! compilerOptions . paths && ( isRootedDiskPath ( literalValue ) || isUrl ( literalValue ) )
563
564
? getCompletionEntriesForRelativeModules ( literalValue , scriptDirectory , compilerOptions , host , scriptPath , extensionOptions )
564
565
: getCompletionEntriesForNonRelativeModules ( literalValue , scriptDirectory , mode , compilerOptions , host , extensionOptions , typeChecker ) ;
565
566
}
@@ -850,13 +851,15 @@ function getCompletionEntriesForNonRelativeModules(
850
851
851
852
const result = createNameAndKindSet ( ) ;
852
853
const moduleResolution = getEmitModuleResolutionKind ( compilerOptions ) ;
854
+
853
855
if ( baseUrl ) {
854
- const projectDir = compilerOptions . project || host . getCurrentDirectory ( ) ;
855
- const absolute = normalizePath ( combinePaths ( projectDir , baseUrl ) ) ;
856
+ const absolute = normalizePath ( combinePaths ( host . getCurrentDirectory ( ) , baseUrl ) ) ;
856
857
getCompletionEntriesForDirectoryFragment ( fragment , absolute , extensionOptions , host , /*moduleSpecifierIsRelative*/ false , /*exclude*/ undefined , result ) ;
857
- if ( paths ) {
858
- addCompletionEntriesFromPaths ( result , fragment , absolute , extensionOptions , host , paths ) ;
859
- }
858
+ }
859
+
860
+ if ( paths ) {
861
+ const absolute = getPathsBasePath ( compilerOptions , host ) ! ;
862
+ addCompletionEntriesFromPaths ( result , fragment , absolute , extensionOptions , host , paths ) ;
860
863
}
861
864
862
865
const fragmentDirectory = getFragmentDirectory ( fragment ) ;
0 commit comments