Skip to content

Commit 8f4ee91

Browse files
author
Yui T
committed
remove external module from showing up on completion list
1 parent 5a33707 commit 8f4ee91

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/services/services.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1687,7 +1687,7 @@ module ts {
16871687
if (displayName && displayName.length >= 2 && firstCharCode === displayName.charCodeAt(displayName.length - 1) &&
16881688
(firstCharCode === CharacterCodes.singleQuote || firstCharCode === CharacterCodes.doubleQuote)) {
16891689
// If the user entered name for the symbol was quoted, removing the quotes is not enough, as the name could be an
1690-
// invalid identifer name. We need to check if whatever was inside the quotes is actually a valid identifier name.
1690+
// invalid identifier name. We need to check if whatever was inside the quotes is actually a valid identifier name.
16911691
displayName = displayName.substring(1, displayName.length - 1);
16921692
}
16931693

@@ -1708,6 +1708,13 @@ module ts {
17081708
// Try to get a valid display name for this symbol, if we could not find one, then ignore it.
17091709
// We would like to only show things that can be added after a dot, so for instance numeric properties can
17101710
// 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 retry the completion list
1714+
// Also name of modules is invalid in completion list (i.e declare module "http" { var x; } | // <= request completion here, "http" should not be there)
1715+
return undefined;
1716+
}
1717+
17111718
var displayName = getValidCompletionEntryDisplayName(symbol.getName(), program.getCompilerOptions().target);
17121719
if (!displayName) {
17131720
return undefined;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/// <reference path="fourslash.ts"/>
2+
3+
//// declare module "http" {
4+
//// var x;
5+
//// }
6+
//// /**/
7+
8+
goTo.marker();
9+
debugger
10+
verifyNegatable.completionListContains("http");

tests/cases/fourslash/fourslash.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,7 @@ function verifyOperationIsCancelled(f) {
630630
var test = new FourSlashInterface.test_();
631631
var goTo = new FourSlashInterface.goTo();
632632
var verify = new FourSlashInterface.verify();
633+
var verifyNegatable = new FourSlashInterface.verifyNegatable(true);
633634
var edit = new FourSlashInterface.edit();
634635
var debug = new FourSlashInterface.debug();
635636
var format = new FourSlashInterface.format();

0 commit comments

Comments
 (0)