vscode-java icon indicating copy to clipboard operation
vscode-java copied to clipboard

"java.saveActions.organizeImports" setting doesn't work on Windows

Open testforstephen opened this issue 2 years ago • 2 comments

This issue is originally created by @alx1024 at https://github.com/microsoft/vscode-java-debug/issues/1071

[provide a description of the issue]

Environment
  • Operating System: Win 10
  • JDK version: 11
  • Visual Studio Code version: 1.62.0
  • Java extension version: 1.0.0
  • Java Debugger extension version: 0.36.0
Steps To Reproduce
  1. In any Java Program in any main-function type "File f = new File("/");"
  2. Save File
Current Result

Even with checkbox checked in settings menu "Java > Save Actions: Organize Imports" (which results in

"java.saveActions.organizeImports": true

in settings.json): imports are not automatically organized

Expected Result

Imports are automatically organized on file save with setting checked

Additional Informations

if you modify the settings.json manually to:

"editor.codeActionsOnSave": { "source.organizeImports": true }

regardless if Java > Save Actions-option is checked, imports work, but you have to search for this solution on Stackoverflow

testforstephen avatar Nov 10 '21 06:11 testforstephen

I just wonder why almost 1 year later and this issue did not fix yet.

itayasaf1990xd avatar Aug 17 '22 11:08 itayasaf1990xd

yeah, for now on my machine it can be solved like this: ignore any settings in the settings UI. And just add this in your settings.json file: "editor.codeActionsOnSave": { "source.organizeImports": true, "source.addMissingImports": true, },

alx1024 avatar Aug 17 '22 12:08 alx1024

still unresolved

adiantek avatar Dec 13 '22 07:12 adiantek

but wait! regardless of saving, copy/paste code should carry imports from the source

having to search for this one was/is a bummer.

avertx avatar Sep 19 '23 19:09 avertx