microsoft / vscode-isort

Import sorting for python using the isort library.
https://marketplace.visualstudio.com/items?itemName=ms-python.isort
MIT License
86 stars 20 forks source link

Add the "Sort Imports" back to the context menu options as "Organize Imports" #343

Open ghost opened 10 months ago

ghost commented 10 months ago

Regarding microsoft/vscode-python#22058, I don't understand the justification for this change. It was removed without adequate replacement.

I am aware of Organize Imports through the command Shift+Alt+o but why was it not added to the right-click context-menu?

In response to microsoft/vscode-python#20233, it is not redundant. Using Code Actions via Ctrl+. or Source Action... from the right-click context menu does not always provide actions for unsorted imports. I fresh installed vs-code and Python with appropriate extensions, opened one of my Python scripts and unsorted the imports, and attempting to use the above no options were provided to sort imports aside from the command for Organize Imports.

Perhaps I'm being pedantic but I like having the option to sort imports via context-menu when reading many files with many lines of code. Two mouse-clicks versus taking my hand off the mouse to press three keys. Fewer actions are better.

I think this change should be reverted such that "Sort Imports" becomes "Organize Imports".

😊 Added smiley face to take off the edge of this lemony request

karthiknadig commented 10 months ago

Thanks for the feature request! We are going to give the community 60 days from when this issue was created to provide 7 👍 upvotes on the opening comment to gauge general interest in this idea. If there's enough upvotes then we will consider this feature request in our future planning. If there's unfortunately not enough upvotes then we will close this issue.

israel-oye commented 10 months ago

We have 8 votes now.

coreybrett commented 9 months ago

This is driving me nuts too

karthiknadig commented 9 months ago

I want to better understand the use case here, in settings you can add:

"[python]": {
        "editor.codeActionsOnSave": {
            "source.organizeImports.isort": "explicit"
        }
    },

This will trigger this automatically on save. Is that not enough?

israel-oye commented 9 months ago

Imo, it's not enough. It is bad UX Let the user have a control over the settings. If there's a way to set it explicitly, there should be a way to do it implicitly as well. Just my two cents. [Hashtag]BringBackOurBelovedMenuOption ✋🏾

ghost commented 9 months ago

I want to better understand the use case here, in settings you can add:

"[python]": {
        "editor.codeActionsOnSave": {
            "source.organizeImports.isort": "explicit"
        }
    },

This will trigger this automatically on save. Is that not enough?

@karthiknadig, the feature request is to revert the following commit that removed a feature and to rename it Organize Imports:

Also, I must be taking crazy pills if what I wrote is unclear.

Use Case:

brettcannon commented 9 months ago
  • An MS developer suggested the removal of a feature and deemed it redundant without justification or replacement.

There was justification, but it was in a meeting about this specific menu item with the wider VS Code team. This decision was not done flippantly or lightly.

  • I opened an issue to address this absurdly random code change.

Please keep the tone cordial or I will lock this issue. It is not absurd and it was not random. You are welcome to disagree with the decision, but rudeness is not okay.

  • I'm not sure why I have to provide a Use Case to revert a code change.

The reason we ask for a use case is we have our reasons for removing and any amount of code has a maintenance cost. As such, we are willing to at least discuss this with you, but it is not a "free" thing to bring the feature back. And honestly, this extension is already a bit "expensive" to maintain due to isort itself not being actively maintained, leading us to work around some bugs with isort.

Also note that if you strongly disagree with us not having the menu item, you can always fork this extension to add it back or create your own extension that just adds the menu item and triggers this extension behind the scenes.

ghost commented 9 months ago

@brettcannon

Thanks for the clarification. The context behind the decision is appreciated.

I have a herd of lemons I'm keeping at bay and one got loose. More dangerous than lemmings!

Given this newfound insight I ask, is a general code sorting solution in development to serve as replacement?

brettcannon commented 9 months ago

Not at the moment. We are talking about it within the team, but no decision has been reached. We got explicitly asked by the wider VS Code team to nest related commands to cut down on vertical real estate in right-click menus, so bringing it back might be a hard sell.

lcmartinezdev commented 6 months ago

I miss a lot the context menu options as well. Please add it again.

ohaucke commented 6 months ago

And here i am, wondering where the "sort" option was hiding. CTRL + . results in a No organize imports action available SHIFT + ALT + o is new to me and a bit cumbersome to remember for someone who only uses python once per quarter CRTL + SHIFT + P and searching for Organize Imports is counter intuitive: i wanna sort them, so i'm searching for sort ...

brettcannon commented 6 months ago

@ohaucke I edited your ✉️ ⬆️ to come off as more 😃 and less 😠, else it would likely would have ended up being hidden.