redhat-developer / redhat-developer/vscode-java

Eclipse Formatter settings for comment length ignored

Open
#3,394 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I have a custom, Eclipse Formatter XML preference file that includes the following Eclipse JDT formatter setting for comment length:

<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="120"/>

I have noticed that, when formatting the code using this settings, comments were always formatted to 80 columns, regardless of the value used. When opening > Java: Open Java Formatter Settings with Preview using the Command Palette, and navigating to the comment section, I noticed that the value in Maximum comment line length is set to 80 -- check out the image below. When modifying this value, my XML file is updated to include the following setting:

<setting id="comment_line_length" value="120"/>

image

It seems that the formatter is picking up its default setting for line length, which is a property name different than the Eclipse JDT Core formatter setting.

Environment
  • Operating System: Amazon Linux 2 (running through SSH)
  • JDK version: 8
  • Visual Studio Code version: the latest (Nov 2023 release)
  • Java extension version: v1.24.0
Steps To Reproduce
  1. Create an Eclipsed Formatter XML file containing the setting org.eclipse.jdt.core.formatter.comment.line_length with a value different than 80.
  2. Write a comment that goes over 80 or the value set for the property above.
  3. Format the code and see the comment being limited to 80 despite the value used in the property above.
Current Result

Comments are formatted to the default value set by comment_line_length instead of the value set by org.eclipse.jdt.core.formatter.comment.line_length.

Expected Result

Comments should be formatted using org.eclipse.jdt.core.formatter.comment.line_length when available.

Additional Informations

Likely related to https://github.com/redhat-developer/vscode-java/issues/2798

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

Reproduce the issue with an Eclipse Formatter XML file and the Java: Open Java Formatter Settings with Preview command, comparing org.eclipse.jdt.core.formatter.comment.line_length with comment_line_length. Trace how the formatter settings are loaded and applied; done means comments use the Eclipse JDT value when it is present, including values other than 80.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, typescript
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.