You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Code formatter does not support additive operator preferences #931
Eclipse code formatting supports a setting that wraps lines after the string concatenation operator (+), along with column formatting that aligns text with one element per line:
public enum SqlQuery {
createChatSchema( "CREATE SCHEMA IF NOT EXISTS chat;" +
"ALTER SCHEMA chat" +
" OWNER TO postgres;" +
"CREATE TABLE IF NOT EXISTS chat.messages_as_json" +
" (id BIGSERIAL PRIMARY KEY, message JSON NOT NULL);" ),
// leaving out constructor, etc.
}
create a type that defines a String that includes wrapping.
auto format the file
Current Result
public enum SqlQuery {
createChatSchema("CREATE SCHEMA IF NOT EXISTS chat;" + "ALTER SCHEMA chat" + " OWNER TO postgres;"
+ "CREATE TABLE IF NOT EXISTS chat.messages_as_json"
+ " (id BIGSERIAL PRIMARY KEY, message JSON NOT NULL);"),
Expected Result
public enum SqlQuery {
createChatSchema( "CREATE SCHEMA IF NOT EXISTS chat;" +
"ALTER SCHEMA chat" +
" OWNER TO postgres;" +
"CREATE TABLE IF NOT EXISTS chat.messages_as_json" +
" (id BIGSERIAL PRIMARY KEY, message JSON NOT NULL);" ),
// leaving out constructor, etc.
}
Tried both user settings and workspace settings. As soon as the Java Language Server starts, the formatter changes the code from the desired layout to the undesired default layout. To be clear, I changed the setting, experimented with the formatter. Saw undesired formatting. Restarted code, waited for the JLS to start, formatted the file. Always the same, no matter what I put in the formatter field, including an invalid value, like “x”.
From: Snjeza<mailto:notifications@github.com>
Sent: July 3, 2019 10:52 PM
To: redhat-developer/vscode-java<mailto:vscode-java@noreply.github.com>
Cc: Robin Coe<mailto:rcoe.javadev@gmail.com>; Mention<mailto:mention@noreply.github.com>
Subject: Re: [redhat-developer/vscode-java] Code formatter does not support additive operator preferences (#931)
I can't reproduce the issue.
Could you set the following:
"java.format.settings.url": "https://raw.githubusercontent.com/snjeza/vscode-test/master/eclipse-formatter.xml"
to your workspace settings.json.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#931?email_source=notifications&email_token=ACZS3FKNP5ZMI53WK5QLA2DP5VQVTA5CNFSM4HOGLTJ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZGFIHQ#issuecomment-508318750>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ACZS3FMWRIEGSQI64NQ5KDDP5VQVTANCNFSM4HOGLTJQ>.
Did more experimentation. I stopped using the GUI settings to set the value and instead edited the json directly. When I opened the settings, I saw a key for maven that Code didn’t recognize, so I deleted it. Then I moved the formatter setting to my user settings, removing it from my workspace settings. I had to remove the key in the file that had a value of “”, which was an artifact left behind when I removed the URI value from the text box. I believe this is a bug – deleting the value should delete the entry from the settings.
After I did this, the formatter started behaving correctly. So, was the problem that code had an invalid key or that there may have been an empty value in one settings file overriding the value in the other?
________________________________
From: Robin Coe <rcoe.javadev@gmail.com>
Sent: Thursday, July 4, 2019 9:48:17 PM
To: redhat-developer/vscode-java; redhat-developer/vscode-java
Cc: Mention
Subject: RE: [redhat-developer/vscode-java] Code formatter does not support additive operator preferences (#931)
Tried both user settings and workspace settings. As soon as the Java Language Server starts, the formatter changes the code from the desired layout to the undesired default layout. To be clear, I changed the setting, experimented with the formatter. Saw undesired formatting. Restarted code, waited for the JLS to start, formatted the file. Always the same, no matter what I put in the formatter field, including an invalid value, like “x”.
From: Snjeza<mailto:notifications@github.com>
Sent: July 3, 2019 10:52 PM
To: redhat-developer/vscode-java<mailto:vscode-java@noreply.github.com>
Cc: Robin Coe<mailto:rcoe.javadev@gmail.com>; Mention<mailto:mention@noreply.github.com>
Subject: Re: [redhat-developer/vscode-java] Code formatter does not support additive operator preferences (#931)
I can't reproduce the issue.
Could you set the following:
"java.format.settings.url": "https://raw.githubusercontent.com/snjeza/vscode-test/master/eclipse-formatter.xml"
to your workspace settings.json.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#931?email_source=notifications&email_token=ACZS3FKNP5ZMI53WK5QLA2DP5VQVTA5CNFSM4HOGLTJ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZGFIHQ#issuecomment-508318750>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ACZS3FMWRIEGSQI64NQ5KDDP5VQVTANCNFSM4HOGLTJQ>.
Experimented with a different computer running the same versions of vscode and plugins. Had the same problem with formatting, until I removed this user setting:
"maven.executable.path": "d:/cygwin64/home/rcoe/apache-maven-3.5.2/bin/mvn"
According to this, microsoft/vscode-maven#79, the maven path is supposed to be supported. If it is, then it breaks the formatter. If it isn’t, that report should not be closed. Either way, surprising that a single key in the settings can break the formatter.
Activity
fbricon commentedon Jun 20, 2019
@snjeza Is this another case of the formatter changes being seemingly ignored? (see #957)
snjeza commentedon Jul 2, 2019
@rdcoe Could you try to use the following file - https://raw.githubusercontent.com/snjeza/vscode-test/master/eclipse-formatter.xml ?
rdcoe commentedon Jul 4, 2019
snjeza commentedon Jul 4, 2019
I can't reproduce the issue.
Could you set the following:
to your workspace settings.json.
rdcoe commentedon Jul 5, 2019
rdcoe commentedon Jul 5, 2019
rdcoe commentedon Jul 5, 2019
dongw00 commentedon Feb 24, 2020
@snjeza Thanks. :)
robstryker commentedon Nov 2, 2026
@shin19991207 It'd be good when you have spare time to check if this is still able to be replicated or not.