redhat-developer / redhat-developer/vscode-java

java formatter: unable to wrap/break long Strings

Open
#3,985 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

code action enhancement
Dominant language
TypeScript
Stars
2.3k
Forks
547
Avg merge
20h 1m
Merged PRs (30d)
11

Description

I come from Intellij idea and I'm used to break long lines with the formatter. I managed to export/import most of the settings, but I can not manage it that vscode breaks long String lines, splitting the Strings with "firstPart" + "secondPart".

These are my related settings in the codeFormatterSettings.json:

<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="180"/>
<setting id="org.eclipse.jdt.core.formatter.formatter_wrap_long_strings" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_strings" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_string_concatenation" value="true"/>

Please ask if I should upload the whole file.

This is an example line of code:

String strSystemPrompt =
                "You are a system that generates a concise and informative answer in less than 100 words for the given question, which is marked with QUESTION. Use the given search results marked with SEARCH RESULT as only knowledge base. Answer questions in the language of the question, i.e. german questions in german and only english questions in english.";

This is the expected output:

String strSystemPrompt =
                "You are a system that generates a concise and informative answer in less than 100 words for the given question, which is marked with QUESTION. Use the given search" + 
                "results marked with SEARCH RESULT as only knowledge base. Answer questions in the language of the question, i.e. german questions in german and only english" + 
                "questions in english.";

Am I missing something, is it not supported, or is it a bug?

VSCode version 1.98.2
Java Language support:
Version
1.40.0
Last Updated
2025-03-06, 08:33:26

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 by reproducing the formatter behavior with the settings shown in codeFormatterSettings.json and the Java example from the issue. Check whether the listed long-string and string-concatenation options reach the Java formatter used by the VS Code extension. Done means long Java string literals are split into concatenated strings as shown in the expected output.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.