Skip to content

Enable auto imports in member snippet completions #46592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

andrewbranch
Copy link
Member

Fixes part of #46568

This duplicates the work of calculating auto-imports between CompletionInfo and CompletionDetails in order to support this without a last-minute protocol change and VS Code update. During 4.6, we can actually just update the protocol and leverage the work done in CompletionInfo, removing the CompletionDetails work, but I think this is alright for the moment.

Kapture.2021-10-29.at.13.36.07.mp4

@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Oct 29, 2021
@@ -6433,6 +6433,11 @@
"category": "Message",
"code": 90053
},
"Includes imports of types referenced by '{0}'": {
Copy link
Member Author

Choose a reason for hiding this comment

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

Note that this is never surfaced by the VS Code UI 🤷

I think that's totally fine, I only made it because the protocol made me have a message to go along with the fix

Copy link
Member

@gabritto gabritto left a comment

Choose a reason for hiding this comment

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

I think this makes sense for a quick win, and like you said, we can deduplicate the import adder efforts later. Thanks ✨

@@ -942,7 +942,7 @@ namespace FourSlash {
expected = typeof expected === "string" ? { name: expected } : expected;

if (actual.insertText !== expected.insertText) {
this.raiseError(`Expected completion insert text to be ${expected.insertText}, got ${actual.insertText}`);
this.raiseError(`Completion insert text did not match: ${showTextDiff(expected.insertText || "", actual.insertText || "")}`);
Copy link
Member

Choose a reason for hiding this comment

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

that's awesome, I've been needing this for a while

Copy link
Member Author

Choose a reason for hiding this comment

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

I usually try to fix things that annoy me about fourslash, it has definitely paid off even if I were the only person using it 😅

@andrewbranch andrewbranch merged commit eeaa595 into microsoft:main Oct 29, 2021
@andrewbranch andrewbranch deleted the feature/member-snippet-auto-imports branch October 29, 2021 21:43
mprobst pushed a commit to mprobst/TypeScript that referenced this pull request Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.

3 participants