@@ -1810,13 +1810,21 @@ module ts {
1810
1810
}
1811
1811
1812
1812
/// Completion
1813
- function getValidCompletionEntryDisplayName ( displayName : string , target : ScriptTarget ) : string {
1813
+ function getValidCompletionEntryDisplayName ( symbol : Symbol , target : ScriptTarget ) : string {
1814
+ var displayName = symbol . getName ( ) ;
1814
1815
if ( displayName && displayName . length > 0 ) {
1815
1816
var firstCharCode = displayName . charCodeAt ( 0 ) ;
1817
+ // First check of the displayName is not external module; if it is an external module, it is not valid entry
1818
+ if ( ( symbol . flags & SymbolFlags . Namespace ) && ( firstCharCode === CharacterCodes . singleQuote || firstCharCode === CharacterCodes . doubleQuote ) ) {
1819
+ // If the symbol is external module, don't show it in the completion list
1820
+ // (i.e declare module "http" { var x; } | // <= request completion here, "http" should not be there)
1821
+ return undefined ;
1822
+ }
1823
+
1816
1824
if ( displayName && displayName . length >= 2 && firstCharCode === displayName . charCodeAt ( displayName . length - 1 ) &&
1817
1825
( firstCharCode === CharacterCodes . singleQuote || firstCharCode === CharacterCodes . doubleQuote ) ) {
1818
1826
// If the user entered name for the symbol was quoted, removing the quotes is not enough, as the name could be an
1819
- // invalid identifer name. We need to check if whatever was inside the quotes is actually a valid identifier name.
1827
+ // invalid identifier name. We need to check if whatever was inside the quotes is actually a valid identifier name.
1820
1828
displayName = displayName . substring ( 1 , displayName . length - 1 ) ;
1821
1829
}
1822
1830
@@ -1825,6 +1833,7 @@ module ts {
1825
1833
isValid = isIdentifierPart ( displayName . charCodeAt ( i ) , target ) ;
1826
1834
}
1827
1835
1836
+
1828
1837
if ( isValid ) {
1829
1838
return displayName ;
1830
1839
}
@@ -1837,7 +1846,7 @@ module ts {
1837
1846
// Try to get a valid display name for this symbol, if we could not find one, then ignore it.
1838
1847
// We would like to only show things that can be added after a dot, so for instance numeric properties can
1839
1848
// not be accessed with a dot (a.1 <- invalid)
1840
- var displayName = getValidCompletionEntryDisplayName ( symbol . getName ( ) , program . getCompilerOptions ( ) . target ) ;
1849
+ var displayName = getValidCompletionEntryDisplayName ( symbol , program . getCompilerOptions ( ) . target ) ;
1841
1850
if ( ! displayName ) {
1842
1851
return undefined ;
1843
1852
}
0 commit comments