Skip to content

Prevent Duplicate String Literal Completions#15754

Merged
mhegazy merged 2 commits into
microsoft:masterfrom
charlespierce:string_literal_completion
May 12, 2017
Merged

Prevent Duplicate String Literal Completions#15754
mhegazy merged 2 commits into
microsoft:masterfrom
charlespierce:string_literal_completion

Conversation

@charlespierce
Copy link
Copy Markdown
Contributor

Fixes #15622

Added optional uniques parameter to addStringLiteralCompletionsFromType to allow for tracking which string literal values have already been added to the list of completions. It appears the only way this could happen would be for function calls with overloads (as given in the original issue).

@msftclas
Copy link
Copy Markdown

@charlespierce,
Thanks for having already signed the Contribution License Agreement. Your agreement was validated by Microsoft. We will now review your pull request.
Thanks,
Microsoft Pull Request Bot

Comment thread src/services/completions.ts Outdated
sortText: "0"
});
const name = (<LiteralType>type).text;
if (!uniques.get(name)) {
Copy link
Copy Markdown

@ghost ghost May 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!uniques.has(name), and uniques.set(name, true) below.

Comment thread src/services/completions.ts Outdated
function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo: SignatureHelp.ArgumentListInfo, typeChecker: TypeChecker): CompletionInfo | undefined {
const candidates: Signature[] = [];
const entries: CompletionEntry[] = [];
const uniques = createMap<string>();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer createMap<true>, since this is just used as a set.

@charlespierce
Copy link
Copy Markdown
Contributor Author

@Andy-MS Updated, thanks!

@mhegazy mhegazy merged commit 1becbf4 into microsoft:master May 12, 2017
@charlespierce charlespierce deleted the string_literal_completion branch May 13, 2017 00:39
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants