@@ -548,39 +548,39 @@ namespace ts.Completions {
548
548
return undefined ;
549
549
}
550
550
551
+ const completionInfo : CompletionInfo = {
552
+ isMemberCompletion : false ,
553
+ /**
554
+ * The user may type in a path that doesn't yet exist, creating a "new identifier"
555
+ * with respect to the collection of identifiers the server is aware of.
556
+ */
557
+ isNewIdentifierLocation : true ,
558
+ entries : [ ]
559
+ } ;
560
+
551
561
const text = sourceFile . text . substr ( range . pos , position - range . pos ) ;
552
562
553
563
const match = tripleSlashDirectiveFragmentRegex . exec ( text ) ;
564
+
554
565
if ( match ) {
555
566
const prefix = match [ 1 ] ;
556
567
const kind = match [ 2 ] ;
557
568
const toComplete = match [ 3 ] ;
558
569
559
570
const scriptPath = getDirectoryPath ( sourceFile . path ) ;
560
- let entries : CompletionEntry [ ] ;
561
571
if ( kind === "path" ) {
562
572
// Give completions for a relative path
563
573
const span : TextSpan = getDirectoryFragmentTextSpan ( toComplete , range . pos + prefix . length ) ;
564
- entries = getCompletionEntriesForDirectoryFragment ( toComplete , scriptPath , getSupportedExtensions ( compilerOptions ) , /*includeExtensions*/ true , span , sourceFile . path ) ;
574
+ completionInfo . entries = getCompletionEntriesForDirectoryFragment ( toComplete , scriptPath , getSupportedExtensions ( compilerOptions ) , /*includeExtensions*/ true , span , sourceFile . path ) ;
565
575
}
566
576
else {
567
577
// Give completions based on the typings available
568
578
const span : TextSpan = { start : range . pos + prefix . length , length : match [ 0 ] . length - prefix . length } ;
569
- entries = getCompletionEntriesFromTypings ( host , compilerOptions , scriptPath , span ) ;
579
+ completionInfo . entries = getCompletionEntriesFromTypings ( host , compilerOptions , scriptPath , span ) ;
570
580
}
571
-
572
- return {
573
- isMemberCompletion : false ,
574
- isNewIdentifierLocation : true ,
575
- entries
576
- } ;
577
581
}
578
582
579
- return {
580
- isMemberCompletion : false ,
581
- isNewIdentifierLocation : false ,
582
- entries : [ ]
583
- } ;
583
+ return completionInfo ;
584
584
}
585
585
586
586
function getCompletionEntriesFromTypings ( host : LanguageServiceHost , options : CompilerOptions , scriptPath : string , span : TextSpan , result : CompletionEntry [ ] = [ ] ) : CompletionEntry [ ] {
0 commit comments