[json] IJPL-63669: fix adding comma at the end of the last item while reformating json with too long lines

(cherry picked from commit b0bbe0e292849ffe85e96d337e05efc42c3cd234)

IJ-MR-189563

GitOrigin-RevId: 8d5be58453f3c4ddfdb36ab3faa985107c46f306
This commit is contained in:
Evgeniia Kirillova
2026-02-02 17:21:38 +00:00
committed by intellij-monorepo-bot
parent f5a587d304
commit 9ff51f73c7
4 changed files with 14 additions and 1 deletions
@@ -40,6 +40,12 @@ public class JsonFormattingTest extends JsonTestCase {
doTest();
}
public void testWrappingWhenLineIsTooLong() {
getCodeStyleSettings().setRightMargin(JsonLanguage.INSTANCE, 20);
getCodeStyleSettings().getCommonSettings(JsonLanguage.INSTANCE).WRAP_LONG_LINES = true;
doTest();
}
// WEB-13587
public void testAlignPropertiesOnColon() {
checkPropertyAlignment(PropertyAlignment.ALIGN_ON_COLON);
@@ -0,0 +1,3 @@
{
"test": "very very very very very very very looooong line"
}
@@ -0,0 +1,3 @@
{
"test": "very very very very very very very looooong line"
}
@@ -132,7 +132,8 @@ public final class LineWrappingUtil {
// No point in splitting line when its left part contains only white spaces, example:
// line start -> | | <- right margin
// | aaaaaaaaaaaaaaaa|aaaaaaaaaaaaaaaaaaaa() <- don't want to wrap this line even if it exceeds right margin
|| CharArrayUtil.shiftBackward(text, startLineOffset, wrapOffset - 1, " \t") < startLineOffset) {
|| CharArrayUtil.shiftBackward(text, startLineOffset, wrapOffset - 1, " \t") < startLineOffset
|| wrapOffset <= startLineOffset || wrapOffset >= endLineOffset) {
continue;
}