Vscode-java: Rename class won't save the file

Created on 9 Apr 2019  路  6Comments  路  Source: redhat-developer/vscode-java

When renaming a class (F2) the class symbol and the file itself are renamed properly. However, when I try to save the file the following error is displayed:

_Failed to save 'NewName.java': The content on disk is newer. Please compare your version with the one on disk._

When I now click on the compare button (part of the error popup) and accept the change then the renamed class is eventually saved.

Environment
  • Operating System: Windows 10
  • JDK version: jdk1.8.0_181
  • Visual Studio Code version: 1.33
  • Java extension version: 0.42.1
Steps To Reproduce
  1. create new file _MyClass.java_
  2. inside _MyClass.java_ expand the template"class" which gives you a skeleton for _MyClass_
  3. position the cursor inside the symbol _MyClass_
  4. press F2 (rename)
  5. enter _NewName_
  6. the mentioned error popup is displayed
  7. press _Compare_
  8. accept new version
  9. _NewName.java_ is saved
Current Result

Extra step to save/ accept the renamed class.

Expected Result

After changing the name of the class via F2, the class symbol as well as the file name are changed and saved.

Additional Informations

When autosave is turned on the error occurs instantly, with autosave turned off the error popup is displayed when saving manually.

vs-code-rename-error

bug regression upstream

Most helpful comment

The problem is fixed in VSCode. You can use the Insiders build until the next official release (1st week of May, probably)

All 6 comments

Reproed this issue on the latest version.

I can reproduce this issue.
Operating System: Windows_NT x64 10.0.17134
JDK version: openjdk version "11.0.2" 2019-01-15
Visual Studio Code version: 1.33.1
Java extension version: 0.42.1

Indeed, this is new. Looks like a bug in vscode, since jdt.ls hasn't changed anything in that area in a long time.

The problem is fixed in VSCode. You can use the Insiders build until the next official release (1st week of May, probably)

Great. I'll wait for the next official release then

Was this page helpful?
0 / 5 - 0 ratings

Related issues

roben picture roben  路  4Comments

ulongx picture ulongx  路  4Comments

yaohaizh picture yaohaizh  路  4Comments

danielcalvogonzalez picture danielcalvogonzalez  路  3Comments

ronniehicks picture ronniehicks  路  3Comments