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

Format document doesn't work when document is not saved #3716

Open
geoff-m opened this issue Jul 20, 2024 · 1 comment
Open

Format document doesn't work when document is not saved #3716

geoff-m opened this issue Jul 20, 2024 · 1 comment

Comments

@geoff-m
Copy link

geoff-m commented Jul 20, 2024

Formatting the document does not work when the document is not saved to disk.

Environment
  • Operating System: Windows 11
  • JDK version: 11
  • Visual Studio Code version: 1.91.1
  • Java extension version: v1.32.0
Steps To Reproduce
  1. File >> New Text File
  2. Put some Java code in the new document that would be changed by formatting. If the language mode is not automatically detected as Java, set it manually.
  3. Right-click anywhere in the document and click Format document.
Current Result

Nothing happens.

Expected Result

The code gets formatted.

@fbricon
Copy link
Collaborator

fbricon commented Jul 20, 2024

Indeed the language server needs a java file to exist in order to perform. Now, you can try creating a new empty file, save it as a .java file, then paste your java code, formatting should work without resaving the file.

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

No branches or pull requests

2 participants