@@ -1851,13 +1851,21 @@ module ts {
18511851 }
18521852
18531853 /// Completion
1854- function getValidCompletionEntryDisplayName ( displayName : string , target : ScriptTarget ) : string {
1854+ function getValidCompletionEntryDisplayName ( symbol : Symbol , target : ScriptTarget ) : string {
1855+ var displayName = symbol . getName ( ) ;
18551856 if ( displayName && displayName . length > 0 ) {
18561857 var firstCharCode = displayName . charCodeAt ( 0 ) ;
1858+ // First check of the displayName is not external module; if it is an external module, it is not valid entry
1859+ if ( ( symbol . flags & SymbolFlags . Namespace ) && ( firstCharCode === CharacterCodes . singleQuote || firstCharCode === CharacterCodes . doubleQuote ) ) {
1860+ // If the symbol is external module, don't show it in the completion list
1861+ // (i.e declare module "http" { var x; } | // <= request completion here, "http" should not be there)
1862+ return undefined ;
1863+ }
1864+
18571865 if ( displayName && displayName . length >= 2 && firstCharCode === displayName . charCodeAt ( displayName . length - 1 ) &&
18581866 ( firstCharCode === CharacterCodes . singleQuote || firstCharCode === CharacterCodes . doubleQuote ) ) {
18591867 // If the user entered name for the symbol was quoted, removing the quotes is not enough, as the name could be an
1860- // invalid identifer name. We need to check if whatever was inside the quotes is actually a valid identifier name.
1868+ // invalid identifier name. We need to check if whatever was inside the quotes is actually a valid identifier name.
18611869 displayName = displayName . substring ( 1 , displayName . length - 1 ) ;
18621870 }
18631871
@@ -1866,6 +1874,7 @@ module ts {
18661874 isValid = isIdentifierPart ( displayName . charCodeAt ( i ) , target ) ;
18671875 }
18681876
1877+
18691878 if ( isValid ) {
18701879 return displayName ;
18711880 }
@@ -1878,7 +1887,7 @@ module ts {
18781887 // Try to get a valid display name for this symbol, if we could not find one, then ignore it.
18791888 // We would like to only show things that can be added after a dot, so for instance numeric properties can
18801889 // not be accessed with a dot (a.1 <- invalid)
1881- var displayName = getValidCompletionEntryDisplayName ( symbol . getName ( ) , program . getCompilerOptions ( ) . target ) ;
1890+ var displayName = getValidCompletionEntryDisplayName ( symbol , program . getCompilerOptions ( ) . target ) ;
18821891 if ( ! displayName ) {
18831892 return undefined ;
18841893 }
0 commit comments