@@ -1851,13 +1851,21 @@ module ts {
1851
1851
}
1852
1852
1853
1853
/// Completion
1854
- function getValidCompletionEntryDisplayName ( displayName : string , target : ScriptTarget ) : string {
1854
+ function getValidCompletionEntryDisplayName ( symbol : Symbol , target : ScriptTarget ) : string {
1855
+ var displayName = symbol . getName ( ) ;
1855
1856
if ( displayName && displayName . length > 0 ) {
1856
1857
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
+
1857
1865
if ( displayName && displayName . length >= 2 && firstCharCode === displayName . charCodeAt ( displayName . length - 1 ) &&
1858
1866
( firstCharCode === CharacterCodes . singleQuote || firstCharCode === CharacterCodes . doubleQuote ) ) {
1859
1867
// 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.
1861
1869
displayName = displayName . substring ( 1 , displayName . length - 1 ) ;
1862
1870
}
1863
1871
@@ -1866,6 +1874,7 @@ module ts {
1866
1874
isValid = isIdentifierPart ( displayName . charCodeAt ( i ) , target ) ;
1867
1875
}
1868
1876
1877
+
1869
1878
if ( isValid ) {
1870
1879
return displayName ;
1871
1880
}
@@ -1878,7 +1887,7 @@ module ts {
1878
1887
// Try to get a valid display name for this symbol, if we could not find one, then ignore it.
1879
1888
// We would like to only show things that can be added after a dot, so for instance numeric properties can
1880
1889
// 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 ) ;
1882
1891
if ( ! displayName ) {
1883
1892
return undefined ;
1884
1893
}
0 commit comments