Skip to content

Commit 37ee8fb

Browse files
committed
Improve JSON prettify
- Fix text wrapping - Do not add additional line breaks to formatted json Fix #4654
1 parent 7a7118d commit 37ee8fb

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/qml/value-editor/editors/MultilineEditor.qml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,8 @@ ColumnLayout
285285
anchors.fill: parent
286286
anchors.margins: 5
287287

288+
verticalScrollBarPolicy: Qt.ScrollBarAlwaysOn
289+
288290
ListView {
289291
id: textView
290292
anchors.fill: parent
@@ -298,7 +300,7 @@ ColumnLayout
298300
NewTextArea {
299301
id: textAreaPart
300302
objectName: "rdm_key_multiline_text_field_" + index
301-
width: textView.width
303+
width: texteditorWrapper.width
302304
height: textAreaPart.contentHeight < texteditorWrapper.height? texteditorWrapper.height - 5 : textAreaPart.contentHeight
303305

304306
enabled: root.enabled

src/qml/value-editor/editors/formatters/formatters.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ var json = {
6161

6262
getFormatted: function (raw, callback) {
6363
try {
64-
return callback("", JSONFormatter.prettyPrint(String(raw)), false, FORMAT_HTML)
64+
// NOTE(u_glide): Minify json before processing to get rid of double formatted JSON
65+
return callback("", JSONFormatter.prettyPrint(JSONFormatter.minify(String(raw))), false, FORMAT_HTML)
6566
} catch (e) {
6667
return callback(qsTranslate("RDM", "Invalid JSON: ") + e)
6768
}

src/qml/value-editor/editors/formatters/json-tools.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ var prettyPrint = function( json ) {
8888

8989
var highlighted = syntaxHighlight(out);
9090

91-
// return out;
92-
return '<pre id="value">' + highlighted + '</pre>';
91+
return '<pre id="value" style="width:97%; white-space: pre-wrap;">' + highlighted + '</pre>';
9392
};
9493

9594

0 commit comments

Comments
 (0)