@@ -1681,9 +1681,17 @@ module ts {
1681
1681
}
1682
1682
1683
1683
/// Completion
1684
- function getValidCompletionEntryDisplayName ( displayName : string , target : ScriptTarget ) : string {
1684
+ function getValidCompletionEntryDisplayName ( symbol : Symbol , target : ScriptTarget ) : string {
1685
+ var displayName = symbol . getName ( ) ;
1685
1686
if ( displayName && displayName . length > 0 ) {
1686
1687
var firstCharCode = displayName . charCodeAt ( 0 ) ;
1688
+ // First check of the displayName is not external module; if it is an external module, it is not valid entry
1689
+ if ( ( symbol . flags & SymbolFlags . Namespace ) && ( firstCharCode === CharacterCodes . singleQuote || firstCharCode === CharacterCodes . doubleQuote ) ) {
1690
+ // If the symbol is external module, don't show it in the completion list
1691
+ // (i.e declare module "http" { var x; } | // <= request completion here, "http" should not be there)
1692
+ return undefined ;
1693
+ }
1694
+
1687
1695
if ( displayName && displayName . length >= 2 && firstCharCode === displayName . charCodeAt ( displayName . length - 1 ) &&
1688
1696
( firstCharCode === CharacterCodes . singleQuote || firstCharCode === CharacterCodes . doubleQuote ) ) {
1689
1697
// If the user entered name for the symbol was quoted, removing the quotes is not enough, as the name could be an
@@ -1696,6 +1704,7 @@ module ts {
1696
1704
isValid = isIdentifierPart ( displayName . charCodeAt ( i ) , target ) ;
1697
1705
}
1698
1706
1707
+
1699
1708
if ( isValid ) {
1700
1709
return displayName ;
1701
1710
}
@@ -1708,14 +1717,7 @@ module ts {
1708
1717
// Try to get a valid display name for this symbol, if we could not find one, then ignore it.
1709
1718
// We would like to only show things that can be added after a dot, so for instance numeric properties can
1710
1719
// not be accessed with a dot (a.1 <- invalid)
1711
- var firstCharCode = symbol . name . charCodeAt ( 0 ) ;
1712
- if ( ( symbol . flags & SymbolFlags . Namespace ) && ( firstCharCode === CharacterCodes . singleQuote || firstCharCode === CharacterCodes . doubleQuote ) ) {
1713
- // If the symbol is external module, don't show it in the completion list
1714
- // (i.e declare module "http" { var x; } | // <= request completion here, "http" should not be there)
1715
- return undefined ;
1716
- }
1717
-
1718
- var displayName = getValidCompletionEntryDisplayName ( symbol . getName ( ) , program . getCompilerOptions ( ) . target ) ;
1720
+ var displayName = getValidCompletionEntryDisplayName ( symbol , program . getCompilerOptions ( ) . target ) ;
1719
1721
if ( ! displayName ) {
1720
1722
return undefined ;
1721
1723
}
0 commit comments