@@ -548,39 +548,39 @@ namespace ts.Completions {
548548 return undefined ;
549549 }
550550
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+
551561 const text = sourceFile . text . substr ( range . pos , position - range . pos ) ;
552562
553563 const match = tripleSlashDirectiveFragmentRegex . exec ( text ) ;
564+
554565 if ( match ) {
555566 const prefix = match [ 1 ] ;
556567 const kind = match [ 2 ] ;
557568 const toComplete = match [ 3 ] ;
558569
559570 const scriptPath = getDirectoryPath ( sourceFile . path ) ;
560- let entries : CompletionEntry [ ] ;
561571 if ( kind === "path" ) {
562572 // Give completions for a relative path
563573 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 ) ;
565575 }
566576 else {
567577 // Give completions based on the typings available
568578 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 ) ;
570580 }
571-
572- return {
573- isMemberCompletion : false ,
574- isNewIdentifierLocation : true ,
575- entries
576- } ;
577581 }
578582
579- return {
580- isMemberCompletion : false ,
581- isNewIdentifierLocation : false ,
582- entries : [ ]
583- } ;
583+ return completionInfo ;
584584 }
585585
586586 function getCompletionEntriesFromTypings ( host : LanguageServiceHost , options : CompilerOptions , scriptPath : string , span : TextSpan , result : CompletionEntry [ ] = [ ] ) : CompletionEntry [ ] {
0 commit comments