redhat-developer / redhat-developer/vscode-java

Formatting a Java file sometimes eats parts of the code

Open
#2,173 13 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

formatter
Dominant language
TypeScript
Stars
2.3k
Forks
546
Avg merge
20h 1m
Merged PRs (30d)
11

Description

This is similar to a bug that existed in Eclipse maybe 5 or 10 years ago.

Every now and then when you press format, part of the code is deleted. This is really super bad for any IDE, especially when you have auto format on save turned on. "Done with your changes? Sure, let me just save and commit. Why did you commit broken code, it doesn't even compile? %#€""

It seems like the formatter and also code highlighting gets out of sync with reality when this happens, e.g. in this example you can see that return is incorrectly colored.

https://user-images.githubusercontent.com/260340/138037841-aabf6088-d086-41f0-9908-98e3ec7eb555.mov

Environment
  • Operating System: mac os Big Sur
  • JDK version: 17
  • Visual Studio Code version: 1.61.1
  • Java extension version: 0.82.0
Steps To Reproduce
  1. Use VS Code until it happens... there is no reliable way as far as I know

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied recording and the formatter and code-highlighting behavior described in the issue, using the listed macOS, JDK 17, VS Code 1.61.1, and Java extension 0.82.0 environment. Reproduce the intermittent failure or narrow down triggering conditions, then verify that formatting no longer deletes code and that highlighting remains synchronized.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, typescript, vscode
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.