Skip to content
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

can we make java.cleanup.actionsOnSave trigger manually with a keyboard shortcut? #3424

Closed
moapu opened this issue Dec 8, 2023 · 3 comments

Comments

@moapu
Copy link

moapu commented Dec 8, 2023

when i want to make a small change to a repo, java.cleanup.actionsOnSave automatically changes lot of the code i wish not to change.
however, I do want this feature available when i really do need it.

following are the ones i have set right now:

  "java.cleanup.actionsOnSave": [
    "addOverride",
    "stringConcatToTextBlock",
    "addFinalModifier",
    "lambdaExpressionFromAnonymousClass",
    "switchExpression",
    "tryWithResource",
    "lambdaExpression"
  ],
Environment
  • Operating System: Windows 10
  • JDK version: 17
  • Visual Studio Code version: 1.84.1
  • Java extension version: v1.25.1
Steps To Reproduce
  1. open a repo
  2. change something slightly
  3. notice it will change lot of the code you are not working with
Additional Information

I simply want a way for the actions to be performed with a keyboard shortcut and not on save every time.

@rgrunber
Copy link
Member

I think this is pretty reasonable. Some code bases may have parts that should not be cleaned up on save, and I don't think VS Code has per-file/folder settings where you could just set "java.cleanup.actionsOnSave": [], and even that isn't as convenient as a keybinding.

This could definitely be done. It's just a matter of whether VS Code provides an existing keybinding we could override, or finding a new one that doesn't clash with anything.

@moapu
Copy link
Author

moapu commented Dec 11, 2023

if you search for java.cleanup.actionsOnSave in command pallette, nothing shows up. meaning there needs to be a command registered first?

@rgrunber
Copy link
Member

java.cleanup.actions will be the new setting to store the list of cleanups to apply. java.saveActions.cleanup will be the setting to enable cleanup actions on save. ctrl+shift+alt+s will be the default key binding to activate cleanups (can be configured through the java.action.doCleanup command ID)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants