Skip to content

Don’t offer import statement completions at from position - #44125

Merged
Andrew Branch (andrewbranch) merged 2 commits into
microsoft:masterfrom
andrewbranch:bug/import-statement-completions-from
May 18, 2021
Merged

Andrew Branch (andrewbranch) merged 2 commits into
microsoft:masterfrom
andrewbranch:bug/import-statement-completions-from

Conversation

@andrewbranch

Copy link
Copy Markdown
Member

❗ Hoping to get this fix into for 4.3. The current state is pretty disruptive if your muscle memory expects a completion for from but you get an import completion instead.

Fixes this:

import statement completions showing auto imports starting with 'f' at 'import {} f'

By making it this:

completions at 'f' now shows 'from' and no auto imports

return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries };
}

function specificKeywordCompletionInfo(keywords: readonly SyntaxKind[]): CompletionInfo {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Making a way to return specific keywords is extra credit beyond just fixing the obvious regression; the behavior in 4.2 was not great:

image

Comment thread src/services/completions.ts Outdated

function specificKeywordCompletionInfo(keywords: readonly SyntaxKind[]): CompletionInfo {
return {
isGlobalCompletion: true,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I tried making this false but the snippets for for loops and stuff still showed up 🤔

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should it be false then?

Matt Bierner (@mjbvz) any idea why that might be happening?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Set to false now despite seeing no difference locally

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems right, but I feel like you should specify isGlobalCompletions as false (or at least get clarity on behavior), and you could also just switch to a cheaper lookup for name.

Once that's done, we can cherry-pick into release-4.3.

Comment thread src/services/completions.ts Resolved
@andrewbranch

Copy link
Copy Markdown
Member Author

TypeScript Bot (@typescript-bot) cherry-pick this to release-4.3

@typescript-bot

TypeScript Bot (typescript-bot) commented May 17, 2021 •

Copy link
Copy Markdown
Contributor

Heya Andrew Branch (@andrewbranch), I've started to run the task to cherry-pick this into release-4.3 on this PR at afa4d05. You can monitor the build here.

@typescript-bot

Copy link
Copy Markdown
Contributor

Hey Andrew Branch (@andrewbranch), I've opened #44136 for you.

TypeScript Bot (typescript-bot) pushed a commit to typescript-bot/TypeScript that referenced this pull request May 17, 2021
Component commits:
34b80a5 Don’t offer import statement completions at `from` position

afa4d05 Set isGlobalCompletion to false, use indexOf lookup
@andrewbranch
Andrew Branch (andrewbranch) merged commit 271e069 into microsoft:master May 18, 2021
@andrewbranch
Andrew Branch (andrewbranch) deleted the bug/import-statement-completions-from branch May 18, 2021 00:48
Andrew Branch (andrewbranch) added a commit that referenced this pull request May 18, 2021
Component commits:
34b80a5 Don’t offer import statement completions at `from` position

afa4d05 Set isGlobalCompletion to false, use indexOf lookup

Co-authored-by: Andrew Branch <andrew@wheream.io>
@microsoft Microsoft (microsoft) locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants