Skip to content

Commit 27e233e

Browse files
committed
Merge branch 'master' into cleanup
2 parents 2e67364 + db0a223 commit 27e233e

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

src/services/services.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,13 +1810,21 @@ module ts {
18101810
}
18111811

18121812
/// Completion
1813-
function getValidCompletionEntryDisplayName(displayName: string, target: ScriptTarget): string {
1813+
function getValidCompletionEntryDisplayName(symbol: Symbol, target: ScriptTarget): string {
1814+
var displayName = symbol.getName();
18141815
if (displayName && displayName.length > 0) {
18151816
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+
18161824
if (displayName && displayName.length >= 2 && firstCharCode === displayName.charCodeAt(displayName.length - 1) &&
18171825
(firstCharCode === CharacterCodes.singleQuote || firstCharCode === CharacterCodes.doubleQuote)) {
18181826
// 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.
18201828
displayName = displayName.substring(1, displayName.length - 1);
18211829
}
18221830

@@ -1825,6 +1833,7 @@ module ts {
18251833
isValid = isIdentifierPart(displayName.charCodeAt(i), target);
18261834
}
18271835

1836+
18281837
if (isValid) {
18291838
return displayName;
18301839
}
@@ -1837,7 +1846,7 @@ module ts {
18371846
// Try to get a valid display name for this symbol, if we could not find one, then ignore it.
18381847
// We would like to only show things that can be added after a dot, so for instance numeric properties can
18391848
// 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);
18411850
if (!displayName) {
18421851
return undefined;
18431852
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/// <reference path="fourslash.ts"/>
2+
3+
//// declare module "http" {
4+
//// var x;
5+
//// /*1*/
6+
//// }
7+
//// declare module 'https' {
8+
//// }
9+
//// /*2*/
10+
11+
goTo.marker("1");
12+
verify.not.completionListContains("http");
13+
goTo.marker("2");
14+
verify.not.completionListContains("http");
15+
verify.not.completionListContains("https");

0 commit comments

Comments
 (0)