-
Notifications
You must be signed in to change notification settings - Fork 54
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
Add "Sort Imports" command to vscode extension & lsp #635
Conversation
let preferences = {}; | ||
let edits = server.organizeImports(project.fileURI('index.ts'), formatting, preferences); | ||
|
||
expect(edits).toEqual([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are their edits if the imports are already sorted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
based on this code: https://github.com/typed-ember/glint/pull/635/files#diff-cadffc59ac4fd3c9fd1cd7488980fc9cfea40cd5a93129f1021c54c810980e20R432
it looks like "that's just the upstream behavior" 🤷
const language = server.getLanguageType(uri); | ||
const formatting = configManager.getFormatCodeSettingsFor(language); | ||
const preferences = configManager.getUserSettingsFor(language); | ||
return server.organizeImports(uri, formatting, preferences); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥳
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for doing this! it's exciting to see more features be added!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for taking this on, @camerondubas! It's super exciting to see new contributors digging in and making hefty contributions like this 🙂
ProtocolRequestType<RequestParams, TextEdit[] | null, void, void, void> | ||
); | ||
|
||
export interface RequestParams { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's arguably incidental that getIR
and sortImports
both just want a uri
param, while other requests might require more (or less!) information. Given that, let's keep separate xParams
/xResult
types for each message.
How does the Sort Imports command work on a project that already has |
@ijlee2 I imagine it would interact in exactly the same way as that plugin does with the built-in "Sort Imports" commands that are provided for regular JS and TS files today. Presumably if you're using the eslint plugin, then you aren't invoking this command and instead are relying on |
@dfreeman Sounds good, thanks for the clarification. |
@camerondubas looks like there are lint failures? Can you address and push? |
d910b61
to
2f1c5b9
Compare
2f1c5b9
to
52a51d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope you don't mind I pushed the lint fixes myself @camerondubas! I have a bit of time this week and wanted to make sure this made it into the release I'll be putting out 🙂
We have a test issue right now that only occurs with the TS nightly build and is only reproducible in CI (💀), but that has nothing to do with your change here, so I think we're good to go. Thank you so much! 🎉
Thanks for getting this in! |
Thx for this feature 🙏 We've been using |
@bartocc Ya I could take a look at that. Should have some time over the next week |
As requested here #626, this adds a "Sort Imports" command to the vscode extension and implements a request in the language server to get the TextEdits needed to organize the imports of the current file.
gts
files as well asts
Recording.2023-10-16.214222.mp4