From 72fa108cbc0a3a7582ca7aaefc46787ec096640a Mon Sep 17 00:00:00 2001 From: zeripath Date: Wed, 2 Feb 2022 08:38:28 +0000 Subject: [PATCH] Fix review excerpt (#18502) (#18530) Backport #18502 Currently the "File Changed" tab of a PR is somehow broken. This is also true for the current release 1.16.0. When you are on the "File Changed" tab, and want to look at code excerpt before or after the code changes, the layout breaks. You can test this on try.gitea.io here: https://try.gitea.io/testnotexisting/magic_enum/pulls/2/files The problem occurs for the unified view and for the split view. Kind of the same problem was there for commenting a line of code, this was fixed in #18321 and #18403. For consistency, I changed the solution of #18321, I removed the ``colspan`` and instead added a ````. The goal was to have code similarly with the split view. Also the separator line in the split view was in the wrong column, this was fixed too.* more consistent unified review comment Fix #18516 Co-authored-by: Andrew Thornton Co-authored-by: confusedsushi --- templates/repo/diff/blob_excerpt.tmpl | 21 +++++++++------------ web_src/js/features/repo-issue.js | 4 +++- web_src/less/_repository.less | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/templates/repo/diff/blob_excerpt.tmpl b/templates/repo/diff/blob_excerpt.tmpl index b3e80881fd..9bf0a7f990 100644 --- a/templates/repo/diff/blob_excerpt.tmpl +++ b/templates/repo/diff/blob_excerpt.tmpl @@ -21,23 +21,18 @@ {{$inlineDiff := $.section.GetComputedInlineDiffFor $line}}{{$inlineDiff.Content}} {{else}} + {{$inlineDiff := $.section.GetComputedInlineDiffFor $line}} + {{if and $line.LeftIdx $inlineDiff.EscapeStatus.Escaped}}{{end}} {{if $line.LeftIdx}}{{end}} {{/* - */}}{{if $line.LeftIdx}}{{/* - */}}{{$inlineDiff := $.section.GetComputedInlineDiffFor $line}}{{$inlineDiff.Content}}{{/* - */}}{{else}}{{/* - */}}{{/* - */}}{{end}}{{/* - */}} + */}}{{if $line.LeftIdx}}{{$inlineDiff.Content}}{{end}}{{/* + */}} + {{if and $line.RightIdx $inlineDiff.EscapeStatus.Escaped}}{{end}} {{if $line.RightIdx}}{{end}} {{/* - */}}{{if $line.RightIdx}}{{/* - */}}{{$inlineDiff := $.section.GetComputedInlineDiffFor $line}}{{$inlineDiff.Content}}{{/* - */}}{{else}}{{/* - */}}{{/* - */}}{{end}}{{/* + */}}{{if $line.RightIdx}}{{$inlineDiff.Content}}{{end}}{{/* */}} {{end}} @@ -67,8 +62,10 @@ {{end}} + {{$inlineDiff := $.section.GetComputedInlineDiffFor $line}} + {{if $inlineDiff.EscapeStatus.Escaped}}{{end}} - {{$inlineDiff := $.section.GetComputedInlineDiffFor $line}}{{$inlineDiff.Content}} + {{$inlineDiff.Content}} {{end}} {{end}} diff --git a/web_src/js/features/repo-issue.js b/web_src/js/features/repo-issue.js index 0523c3fb01..ce4981fbe3 100644 --- a/web_src/js/features/repo-issue.js +++ b/web_src/js/features/repo-issue.js @@ -504,7 +504,9 @@ export function initRepoPullRequestReview() { ` : ` - + + + `} `); diff --git a/web_src/less/_repository.less b/web_src/less/_repository.less index 75ccc8d25f..18c463bf18 100644 --- a/web_src/less/_repository.less +++ b/web_src/less/_repository.less @@ -3186,7 +3186,7 @@ td.blob-excerpt { background: var(--color-diff-inactive); } -.code-diff-split tbody tr td:nth-child(4) { +.code-diff-split tbody tr td:nth-child(5) { border-left: 1px solid var(--color-secondary); }