Skip to content

Commit 172fcdc

Browse files
fix(compare): improve response body rendering
1 parent 8fc0064 commit 172fcdc

2 files changed

Lines changed: 48 additions & 8 deletions

File tree

DebugProbe.AspNetCore/Assets/css/debugprobe.css

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -681,24 +681,29 @@ tbody tr:last-child td {
681681

682682
.code-block {
683683
position: relative;
684+
min-width: 0;
684685
border-top: 1px solid #2d3748;
685686
}
686687

687688
.code-block pre {
688689
min-height: 18px;
689-
max-height: 360px;
690+
max-height: 420px;
690691
margin: 0;
691692
}
692693

693694
pre {
694-
overflow: auto;
695+
box-sizing: border-box;
696+
max-width: 100%;
697+
overflow-x: auto;
698+
overflow-y: auto;
695699
margin: 0;
696700
padding: 12px 84px 12px 12px;
697701
background: #1e1e1e;
698702
border-radius: 0 0 6px 6px;
699703
color: #dcdcdc;
700704
font-size: 13px;
701705
line-height: 1.4;
706+
white-space: pre;
702707
tab-size: 2;
703708
}
704709

@@ -709,6 +714,7 @@ pre {
709714
.json-compare {
710715
display: grid;
711716
grid-template-columns: repeat(2, minmax(0, 1fr));
717+
align-items: stretch;
712718
gap: 10px;
713719
}
714720

@@ -776,7 +782,30 @@ pre {
776782
}
777783

778784
.compare-pane {
785+
display: flex;
786+
flex-direction: column;
779787
min-width: 0;
788+
min-height: 0;
789+
}
790+
791+
.compare-pane .code-block {
792+
display: flex;
793+
flex: 1 1 auto;
794+
flex-direction: column;
795+
min-height: 0;
796+
max-height: 420px;
797+
overflow: hidden;
798+
border-radius: 0 0 6px 6px;
799+
}
800+
801+
.compare-pane .code-block pre {
802+
flex: 1 1 auto;
803+
height: 100%;
804+
max-height: none;
805+
}
806+
807+
.compare-pane .compare-empty {
808+
flex: 1 1 auto;
780809
}
781810

782811
.compare-pane-title {
@@ -923,10 +952,13 @@ pre {
923952
========================= */
924953

925954
.diff-line {
955+
box-sizing: border-box;
956+
width: max-content;
926957
min-height: 18px;
927-
padding-left: 6px;
958+
padding: 0 6px;
928959
background: rgba(255, 200, 0, 0.12);
929960
border-left: 3px solid #f1c40f;
961+
white-space: pre;
930962
}
931963

932964
.diff-line-added {

DebugProbe.AspNetCore/Assets/js/debugprobe-compare-engine.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,13 @@
1515

1616
if ((!local.ok && !localEmpty) || (!remote.ok && !remoteEmpty)) {
1717
return {
18-
local: (localEmpty ? '(empty)' : local.raw)
19-
.split('\n')
18+
local: linesForParsedOrRaw(local, localEmpty)
2019
.map(x => ({
2120
text: x,
2221
state: !local.ok && !localEmpty ? 'invalid' : ''
2322
})),
2423

25-
remote: (remoteEmpty ? '(empty)' : remote.raw)
26-
.split('\n')
24+
remote: linesForParsedOrRaw(remote, remoteEmpty)
2725
.map(x => ({
2826
text: x,
2927
state: !remote.ok && !remoteEmpty ? 'invalid' : ''
@@ -68,6 +66,16 @@
6866
return rows;
6967
}
7068

69+
function linesForParsedOrRaw(payload, empty) {
70+
if (empty) {
71+
return ['(empty)'];
72+
}
73+
74+
return payload.ok
75+
? stringifyLines(payload.value, 0, false)
76+
: payload.raw.split('\n');
77+
}
78+
7179
function parseJson(json) {
7280
if (!json || json.trim() === '') {
7381
return {
@@ -816,4 +824,4 @@ function indent(depth) {
816824
return ' '.repeat(depth);
817825
}
818826

819-
window.compareJsonBodies = compareJsonBodies;
827+
window.compareJsonBodies = compareJsonBodies;

0 commit comments

Comments
 (0)