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

Renaming the primary type declaration should update the source file name #3408

Closed
loralei28 opened this issue Nov 30, 2023 · 2 comments
Closed
Assignees

Comments

@loralei28
Copy link

loralei28 commented Nov 30, 2023

Environment
  • Operating System: win/mac
  • JDK version: 17.0.8
  • Visual Studio Code version:1.84.2
  • Java extension version:1.25.0
Steps To Reproduce

1.Open an empty VS Code window
2.Drag a Java file https://github.com/redhat-developer/vscode-java/blob/master/test/resources/projects/eclipse/simple-app/src/app/App.java to it.
3.Change the class name to "App2"

Current Result

image

@loralei28 loralei28 changed the title After single file updates class name, file name will not be automatically updated at the same time After updating the class name in the single file, the file name will not be automatically updated at the same time. Nov 30, 2023
@testforstephen testforstephen changed the title After updating the class name in the single file, the file name will not be automatically updated at the same time. After renaming the class name in the single file, the file name is not automatically updated at the same time. Nov 30, 2023
@hopehadfield hopehadfield self-assigned this Jan 10, 2024
@rgrunber
Copy link
Member

rgrunber commented Feb 28, 2024

I assume we are leaning towards updating the file on save because updating while the user is typing would be very annoying. However, with https://code.visualstudio.com/docs/editor/codebasics#_save-auto-save , this could also make the feature just as annoying.

We might need to consider making some setting that automatically disables this functionality when auto-save is enabled.

@rgrunber rgrunber changed the title After renaming the class name in the single file, the file name is not automatically updated at the same time. Renaming the primary type declaration should update the source file name Feb 28, 2024
@rgrunber
Copy link
Member

This is now possible by ensuring the java.cleanup.actions setting includes the element : "renameFileToType" within the array value. It has also been set as the default option if a user has not overridden the setting with their own preferences.

Basically having

settings.json

...
"java.cleanup.actions": [
  "renameFileToType"
]
...

@rgrunber rgrunber added this to the End March 2024 milestone Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

3 participants