fix(web): size split diff columns from a colgroup and wrap long lines
- commit
- e84f160db4eada9fdd7ce1ed1aadcc5dfa24e76c
- author
- brice · · 2026-10-11 12:42 UTC
- parent
- bcc3a12
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
9 files · +88 -8
M cmd/ermite/testdata/web/commit-merge.html +8 -0
| @@ -131,6 +131,14 @@ | |||
| 131 | 131 | </tbody> | |
| 132 | 132 | </table> | |
| 133 | 133 | <table class="dt spl" aria-label="side.txt, split"> | |
| 134 | + | <colgroup> | |
| 135 | + | <col class="c-ln"> | |
| 136 | + | <col class="c-m"> | |
| 137 | + | <col> | |
| 138 | + | <col class="c-ln"> | |
| 139 | + | <col class="c-m"> | |
| 140 | + | <col> | |
| 141 | + | </colgroup> | |
| 134 | 142 | <tbody> | |
| 135 | 143 | <tr class="hunk"> | |
| 136 | 144 | <td colspan="6">@@ -0,0 +1,1 @@</td> | |
| @@ -131,6 +131,14 @@ | |||||
| 131 | </tbody> | 131 | </tbody> | ||
| 132 | </table> | 132 | </table> | ||
| 133 | <table class="dt spl" aria-label="side.txt, split"> | 133 | <table class="dt spl" aria-label="side.txt, split"> | ||
| 134 | + | <colgroup> | |||
| 135 | + | <col class="c-ln"> | |||
| 136 | + | <col class="c-m"> | |||
| 137 | + | <col> | |||
| 138 | + | <col class="c-ln"> | |||
| 139 | + | <col class="c-m"> | |||
| 140 | + | <col> | |||
| 141 | + | </colgroup> | |||
| 134 | <tbody> | 142 | <tbody> | ||
| 135 | <tr class="hunk"> | 143 | <tr class="hunk"> | ||
| 136 | <td colspan="6">@@ -0,0 +1,1 @@</td> | 144 | <td colspan="6">@@ -0,0 +1,1 @@</td> | ||
M cmd/ermite/testdata/web/commit-modify-split.html +8 -0
| @@ -180,6 +180,14 @@ And <b>html</b> & "quotes".</pre> | |||
| 180 | 180 | </tbody> | |
| 181 | 181 | </table> | |
| 182 | 182 | <table class="dt spl" aria-label="a.txt, split"> | |
| 183 | + | <colgroup> | |
| 184 | + | <col class="c-ln"> | |
| 185 | + | <col class="c-m"> | |
| 186 | + | <col> | |
| 187 | + | <col class="c-ln"> | |
| 188 | + | <col class="c-m"> | |
| 189 | + | <col> | |
| 190 | + | </colgroup> | |
| 183 | 191 | <tbody> | |
| 184 | 192 | <tr class="hunk"> | |
| 185 | 193 | <td colspan="6">@@ -1,5 +1,6 @@</td> | |
| @@ -180,6 +180,14 @@ And <b>html</b> & "quotes".</pre> | |||||
| 180 | </tbody> | 180 | </tbody> | ||
| 181 | </table> | 181 | </table> | ||
| 182 | <table class="dt spl" aria-label="a.txt, split"> | 182 | <table class="dt spl" aria-label="a.txt, split"> | ||
| 183 | + | <colgroup> | |||
| 184 | + | <col class="c-ln"> | |||
| 185 | + | <col class="c-m"> | |||
| 186 | + | <col> | |||
| 187 | + | <col class="c-ln"> | |||
| 188 | + | <col class="c-m"> | |||
| 189 | + | <col> | |||
| 190 | + | </colgroup> | |||
| 183 | <tbody> | 191 | <tbody> | ||
| 184 | <tr class="hunk"> | 192 | <tr class="hunk"> | ||
| 185 | <td colspan="6">@@ -1,5 +1,6 @@</td> | 193 | <td colspan="6">@@ -1,5 +1,6 @@</td> | ||
M cmd/ermite/testdata/web/commit-modify.html +8 -0
| @@ -180,6 +180,14 @@ And <b>html</b> & "quotes".</pre> | |||
| 180 | 180 | </tbody> | |
| 181 | 181 | </table> | |
| 182 | 182 | <table class="dt spl" aria-label="a.txt, split"> | |
| 183 | + | <colgroup> | |
| 184 | + | <col class="c-ln"> | |
| 185 | + | <col class="c-m"> | |
| 186 | + | <col> | |
| 187 | + | <col class="c-ln"> | |
| 188 | + | <col class="c-m"> | |
| 189 | + | <col> | |
| 190 | + | </colgroup> | |
| 183 | 191 | <tbody> | |
| 184 | 192 | <tr class="hunk"> | |
| 185 | 193 | <td colspan="6">@@ -1,5 +1,6 @@</td> | |
| @@ -180,6 +180,14 @@ And <b>html</b> & "quotes".</pre> | |||||
| 180 | </tbody> | 180 | </tbody> | ||
| 181 | </table> | 181 | </table> | ||
| 182 | <table class="dt spl" aria-label="a.txt, split"> | 182 | <table class="dt spl" aria-label="a.txt, split"> | ||
| 183 | + | <colgroup> | |||
| 184 | + | <col class="c-ln"> | |||
| 185 | + | <col class="c-m"> | |||
| 186 | + | <col> | |||
| 187 | + | <col class="c-ln"> | |||
| 188 | + | <col class="c-m"> | |||
| 189 | + | <col> | |||
| 190 | + | </colgroup> | |||
| 183 | <tbody> | 191 | <tbody> | ||
| 184 | <tr class="hunk"> | 192 | <tr class="hunk"> | ||
| 185 | <td colspan="6">@@ -1,5 +1,6 @@</td> | 193 | <td colspan="6">@@ -1,5 +1,6 @@</td> | ||
M cmd/ermite/testdata/web/commit-rename.html +8 -0
| @@ -142,6 +142,14 @@ | |||
| 142 | 142 | </tbody> | |
| 143 | 143 | </table> | |
| 144 | 144 | <table class="dt spl" aria-label="gone.txt, split"> | |
| 145 | + | <colgroup> | |
| 146 | + | <col class="c-ln"> | |
| 147 | + | <col class="c-m"> | |
| 148 | + | <col> | |
| 149 | + | <col class="c-ln"> | |
| 150 | + | <col class="c-m"> | |
| 151 | + | <col> | |
| 152 | + | </colgroup> | |
| 145 | 153 | <tbody> | |
| 146 | 154 | <tr class="hunk"> | |
| 147 | 155 | <td colspan="6">@@ -1,1 +0,0 @@</td> | |
| @@ -142,6 +142,14 @@ | |||||
| 142 | </tbody> | 142 | </tbody> | ||
| 143 | </table> | 143 | </table> | ||
| 144 | <table class="dt spl" aria-label="gone.txt, split"> | 144 | <table class="dt spl" aria-label="gone.txt, split"> | ||
| 145 | + | <colgroup> | |||
| 146 | + | <col class="c-ln"> | |||
| 147 | + | <col class="c-m"> | |||
| 148 | + | <col> | |||
| 149 | + | <col class="c-ln"> | |||
| 150 | + | <col class="c-m"> | |||
| 151 | + | <col> | |||
| 152 | + | </colgroup> | |||
| 145 | <tbody> | 153 | <tbody> | ||
| 146 | <tr class="hunk"> | 154 | <tr class="hunk"> | ||
| 147 | <td colspan="6">@@ -1,1 +0,0 @@</td> | 155 | <td colspan="6">@@ -1,1 +0,0 @@</td> | ||
M cmd/ermite/testdata/web/commit-root.html +32 -0
| @@ -158,6 +158,14 @@ | |||
| 158 | 158 | </tbody> | |
| 159 | 159 | </table> | |
| 160 | 160 | <table class="dt spl" aria-label="a.txt, split"> | |
| 161 | + | <colgroup> | |
| 162 | + | <col class="c-ln"> | |
| 163 | + | <col class="c-m"> | |
| 164 | + | <col> | |
| 165 | + | <col class="c-ln"> | |
| 166 | + | <col class="c-m"> | |
| 167 | + | <col> | |
| 168 | + | </colgroup> | |
| 161 | 169 | <tbody> | |
| 162 | 170 | <tr class="hunk"> | |
| 163 | 171 | <td colspan="6">@@ -0,0 +1,5 @@</td> | |
| @@ -244,6 +252,14 @@ | |||
| 244 | 252 | </tbody> | |
| 245 | 253 | </table> | |
| 246 | 254 | <table class="dt spl" aria-label="gone.txt, split"> | |
| 255 | + | <colgroup> | |
| 256 | + | <col class="c-ln"> | |
| 257 | + | <col class="c-m"> | |
| 258 | + | <col> | |
| 259 | + | <col class="c-ln"> | |
| 260 | + | <col class="c-m"> | |
| 261 | + | <col> | |
| 262 | + | </colgroup> | |
| 247 | 263 | <tbody> | |
| 248 | 264 | <tr class="hunk"> | |
| 249 | 265 | <td colspan="6">@@ -0,0 +1,1 @@</td> | |
| @@ -310,6 +326,14 @@ | |||
| 310 | 326 | </tbody> | |
| 311 | 327 | </table> | |
| 312 | 328 | <table class="dt spl" aria-label="old.txt, split"> | |
| 329 | + | <colgroup> | |
| 330 | + | <col class="c-ln"> | |
| 331 | + | <col class="c-m"> | |
| 332 | + | <col> | |
| 333 | + | <col class="c-ln"> | |
| 334 | + | <col class="c-m"> | |
| 335 | + | <col> | |
| 336 | + | </colgroup> | |
| 313 | 337 | <tbody> | |
| 314 | 338 | <tr class="hunk"> | |
| 315 | 339 | <td colspan="6">@@ -0,0 +1,3 @@</td> | |
| @@ -381,6 +405,14 @@ | |||
| 381 | 405 | </tbody> | |
| 382 | 406 | </table> | |
| 383 | 407 | <table class="dt spl" aria-label="run.sh, split"> | |
| 408 | + | <colgroup> | |
| 409 | + | <col class="c-ln"> | |
| 410 | + | <col class="c-m"> | |
| 411 | + | <col> | |
| 412 | + | <col class="c-ln"> | |
| 413 | + | <col class="c-m"> | |
| 414 | + | <col> | |
| 415 | + | </colgroup> | |
| 384 | 416 | <tbody> | |
| 385 | 417 | <tr class="hunk"> | |
| 386 | 418 | <td colspan="6">@@ -0,0 +1,2 @@</td> | |
| @@ -158,6 +158,14 @@ | |||||
| 158 | </tbody> | 158 | </tbody> | ||
| 159 | </table> | 159 | </table> | ||
| 160 | <table class="dt spl" aria-label="a.txt, split"> | 160 | <table class="dt spl" aria-label="a.txt, split"> | ||
| 161 | + | <colgroup> | |||
| 162 | + | <col class="c-ln"> | |||
| 163 | + | <col class="c-m"> | |||
| 164 | + | <col> | |||
| 165 | + | <col class="c-ln"> | |||
| 166 | + | <col class="c-m"> | |||
| 167 | + | <col> | |||
| 168 | + | </colgroup> | |||
| 161 | <tbody> | 169 | <tbody> | ||
| 162 | <tr class="hunk"> | 170 | <tr class="hunk"> | ||
| 163 | <td colspan="6">@@ -0,0 +1,5 @@</td> | 171 | <td colspan="6">@@ -0,0 +1,5 @@</td> | ||
| @@ -244,6 +252,14 @@ | |||||
| 244 | </tbody> | 252 | </tbody> | ||
| 245 | </table> | 253 | </table> | ||
| 246 | <table class="dt spl" aria-label="gone.txt, split"> | 254 | <table class="dt spl" aria-label="gone.txt, split"> | ||
| 255 | + | <colgroup> | |||
| 256 | + | <col class="c-ln"> | |||
| 257 | + | <col class="c-m"> | |||
| 258 | + | <col> | |||
| 259 | + | <col class="c-ln"> | |||
| 260 | + | <col class="c-m"> | |||
| 261 | + | <col> | |||
| 262 | + | </colgroup> | |||
| 247 | <tbody> | 263 | <tbody> | ||
| 248 | <tr class="hunk"> | 264 | <tr class="hunk"> | ||
| 249 | <td colspan="6">@@ -0,0 +1,1 @@</td> | 265 | <td colspan="6">@@ -0,0 +1,1 @@</td> | ||
| @@ -310,6 +326,14 @@ | |||||
| 310 | </tbody> | 326 | </tbody> | ||
| 311 | </table> | 327 | </table> | ||
| 312 | <table class="dt spl" aria-label="old.txt, split"> | 328 | <table class="dt spl" aria-label="old.txt, split"> | ||
| 329 | + | <colgroup> | |||
| 330 | + | <col class="c-ln"> | |||
| 331 | + | <col class="c-m"> | |||
| 332 | + | <col> | |||
| 333 | + | <col class="c-ln"> | |||
| 334 | + | <col class="c-m"> | |||
| 335 | + | <col> | |||
| 336 | + | </colgroup> | |||
| 313 | <tbody> | 337 | <tbody> | ||
| 314 | <tr class="hunk"> | 338 | <tr class="hunk"> | ||
| 315 | <td colspan="6">@@ -0,0 +1,3 @@</td> | 339 | <td colspan="6">@@ -0,0 +1,3 @@</td> | ||
| @@ -381,6 +405,14 @@ | |||||
| 381 | </tbody> | 405 | </tbody> | ||
| 382 | </table> | 406 | </table> | ||
| 383 | <table class="dt spl" aria-label="run.sh, split"> | 407 | <table class="dt spl" aria-label="run.sh, split"> | ||
| 408 | + | <colgroup> | |||
| 409 | + | <col class="c-ln"> | |||
| 410 | + | <col class="c-m"> | |||
| 411 | + | <col> | |||
| 412 | + | <col class="c-ln"> | |||
| 413 | + | <col class="c-m"> | |||
| 414 | + | <col> | |||
| 415 | + | </colgroup> | |||
| 384 | <tbody> | 416 | <tbody> | ||
| 385 | <tr class="hunk"> | 417 | <tr class="hunk"> | ||
| 386 | <td colspan="6">@@ -0,0 +1,2 @@</td> | 418 | <td colspan="6">@@ -0,0 +1,2 @@</td> | ||
M cmd/ermite/testdata/web/commit-trojan.html +8 -0
| @@ -186,6 +186,14 @@ | |||
| 186 | 186 | </tbody> | |
| 187 | 187 | </table> | |
| 188 | 188 | <table class="dt spl" aria-label="evil.go, split"> | |
| 189 | + | <colgroup> | |
| 190 | + | <col class="c-ln"> | |
| 191 | + | <col class="c-m"> | |
| 192 | + | <col> | |
| 193 | + | <col class="c-ln"> | |
| 194 | + | <col class="c-m"> | |
| 195 | + | <col> | |
| 196 | + | </colgroup> | |
| 189 | 197 | <tbody> | |
| 190 | 198 | <tr class="hunk"> | |
| 191 | 199 | <td colspan="6">@@ -0,0 +1,8 @@</td> | |
| @@ -186,6 +186,14 @@ | |||||
| 186 | </tbody> | 186 | </tbody> | ||
| 187 | </table> | 187 | </table> | ||
| 188 | <table class="dt spl" aria-label="evil.go, split"> | 188 | <table class="dt spl" aria-label="evil.go, split"> | ||
| 189 | + | <colgroup> | |||
| 190 | + | <col class="c-ln"> | |||
| 191 | + | <col class="c-m"> | |||
| 192 | + | <col> | |||
| 193 | + | <col class="c-ln"> | |||
| 194 | + | <col class="c-m"> | |||
| 195 | + | <col> | |||
| 196 | + | </colgroup> | |||
| 189 | <tbody> | 197 | <tbody> | ||
| 190 | <tr class="hunk"> | 198 | <tr class="hunk"> | ||
| 191 | <td colspan="6">@@ -0,0 +1,8 @@</td> | 199 | <td colspan="6">@@ -0,0 +1,8 @@</td> | ||
M internal/adapters/web/diff.templ +1 -0
| @@ -193,6 +193,7 @@ templ DiffFileView(f DiffFile, p DiffView) { | |||
| 193 | 193 | } | |
| 194 | 194 | if p.ShowSplit { | |
| 195 | 195 | <table class="dt spl" aria-label={ f.Path + ", split" }> | |
| 196 | + | <colgroup><col class="c-ln"/><col class="c-m"/><col/><col class="c-ln"/><col class="c-m"/><col/></colgroup> | |
| 196 | 197 | for _, h := range f.Hunks { | |
| 197 | 198 | <tbody> | |
| 198 | 199 | <tr class="hunk"><td colspan="6">{ h.Header }</td></tr> | |
| @@ -193,6 +193,7 @@ templ DiffFileView(f DiffFile, p DiffView) { | |||||
| 193 | } | 193 | } | ||
| 194 | if p.ShowSplit { | 194 | if p.ShowSplit { | ||
| 195 | <table class="dt spl" aria-label={ f.Path + ", split" }> | 195 | <table class="dt spl" aria-label={ f.Path + ", split" }> | ||
| 196 | + | <colgroup><col class="c-ln"/><col class="c-m"/><col/><col class="c-ln"/><col class="c-m"/><col/></colgroup> | |||
| 196 | for _, h := range f.Hunks { | 197 | for _, h := range f.Hunks { | ||
| 197 | <tbody> | 198 | <tbody> | ||
| 198 | <tr class="hunk"><td colspan="6">{ h.Header }</td></tr> | 199 | <tr class="hunk"><td colspan="6">{ h.Header }</td></tr> | ||
M internal/adapters/web/diff_templ.go +7 -7 generated file: collapsed
M internal/adapters/web/static/css/50-code.css +8 -1
| @@ -79,7 +79,14 @@ | |||
| 79 | 79 | & .none { background: var(--paper-alt); } | |
| 80 | 80 | } | |
| 81 | 81 | .dscroll { overflow-x: auto; background: var(--bg-surface); border: 1px solid var(--border); border-top: 0; border-radius: 0 0 var(--r) var(--r); } | |
| 82 | - | .spl { width: 100%; table-layout: fixed; & .tx { overflow: hidden; text-overflow: ellipsis; } & .ln { width: 6ch; } & .m { width: 2ch; } } | |
| 82 | + | /* split: a fixed layout takes its widths from the colgroup (the first row is | |
| 83 | + | the hunk header, which spans all columns); long lines wrap in their half */ | |
| 84 | + | .spl { | |
| 85 | + | width: 100%; table-layout: fixed; | |
| 86 | + | & .c-ln { width: 7ch; } & .c-m { width: 2.5ch; } | |
| 87 | + | & .tx, & .hunk td { white-space: pre-wrap; overflow-wrap: anywhere; } | |
| 88 | + | & td.ln:nth-child(4) { border-left: 1px solid var(--border); } | |
| 89 | + | } | |
| 83 | 90 | #diffs[data-diff="unified"] .spl, #diffs[data-diff="split"] .uni { display: none; } | |
| 84 | 91 | ||
| 85 | 92 | /* diff table of contents in the rail */ | |
| @@ -79,7 +79,14 @@ | |||||
| 79 | & .none { background: var(--paper-alt); } | 79 | & .none { background: var(--paper-alt); } | ||
| 80 | } | 80 | } | ||
| 81 | .dscroll { overflow-x: auto; background: var(--bg-surface); border: 1px solid var(--border); border-top: 0; border-radius: 0 0 var(--r) var(--r); } | 81 | .dscroll { overflow-x: auto; background: var(--bg-surface); border: 1px solid var(--border); border-top: 0; border-radius: 0 0 var(--r) var(--r); } | ||
| 82 | - | .spl { width: 100%; table-layout: fixed; & .tx { overflow: hidden; text-overflow: ellipsis; } & .ln { width: 6ch; } & .m { width: 2ch; } } | 82 | + | /* split: a fixed layout takes its widths from the colgroup (the first row is |
| 83 | + | the hunk header, which spans all columns); long lines wrap in their half */ | |||
| 84 | + | .spl { | |||
| 85 | + | width: 100%; table-layout: fixed; | |||
| 86 | + | & .c-ln { width: 7ch; } & .c-m { width: 2.5ch; } | |||
| 87 | + | & .tx, & .hunk td { white-space: pre-wrap; overflow-wrap: anywhere; } | |||
| 88 | + | & td.ln:nth-child(4) { border-left: 1px solid var(--border); } | |||
| 89 | + | } | |||
| 83 | #diffs[data-diff="unified"] .spl, #diffs[data-diff="split"] .uni { display: none; } | 90 | #diffs[data-diff="unified"] .spl, #diffs[data-diff="split"] .uni { display: none; } | ||
| 84 | 91 | ||||
| 85 | /* diff table of contents in the rail */ | 92 | /* diff table of contents in the rail */ | ||