Skip to content

Commit cb9d8aa

Browse files
committed
feat(diff): Enable commenting on expanded lines in PR diffs
1 parent 22b92e3 commit cb9d8aa

File tree

7 files changed

+258
-28
lines changed

7 files changed

+258
-28
lines changed

routers/web/repo/compare.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"net/http"
1515
"net/url"
1616
"path/filepath"
17+
"sort"
1718
"strings"
1819

1920
"code.gitea.io/gitea/models/db"
@@ -43,6 +44,7 @@ import (
4344
"code.gitea.io/gitea/services/context/upload"
4445
"code.gitea.io/gitea/services/gitdiff"
4546
pull_service "code.gitea.io/gitea/services/pull"
47+
user_service "code.gitea.io/gitea/services/user"
4648
)
4749

4850
const (
@@ -947,6 +949,41 @@ func ExcerptBlob(ctx *context.Context) {
947949
section.Lines = append(section.Lines, lineSection)
948950
}
949951
}
952+
if ctx.Doer != nil {
953+
ctx.Data["SignedUserID"] = ctx.Doer.ID
954+
}
955+
isPull := ctx.FormBool("is_pull")
956+
ctx.Data["PageIsPullFiles"] = isPull
957+
958+
if isPull {
959+
issueIndex := ctx.FormInt64("issue_index")
960+
ctx.Data["IssueIndex"] = issueIndex
961+
if issueIndex > 0 {
962+
if issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, issueIndex); err == nil && issue.IsPull {
963+
ctx.Data["Issue"] = issue
964+
ctx.Data["CanBlockUser"] = func(blocker, blockee *user_model.User) bool {
965+
return user_service.CanBlockUser(ctx, ctx.Doer, blocker, blockee)
966+
}
967+
968+
if allComments, err := issues_model.FetchCodeComments(ctx, issue, ctx.Doer, ctx.FormBool("show_outdated")); err == nil {
969+
if lineComments, ok := allComments[filePath]; ok {
970+
for _, line := range section.Lines {
971+
if comments, ok := lineComments[int64(line.LeftIdx*-1)]; ok {
972+
line.Comments = append(line.Comments, comments...)
973+
}
974+
if comments, ok := lineComments[int64(line.RightIdx)]; ok {
975+
line.Comments = append(line.Comments, comments...)
976+
}
977+
sort.SliceStable(line.Comments, func(i, j int) bool {
978+
return line.Comments[i].CreatedUnix < line.Comments[j].CreatedUnix
979+
})
980+
}
981+
}
982+
}
983+
}
984+
}
985+
}
986+
950987
ctx.Data["section"] = section
951988
ctx.Data["FileNameHash"] = git.HashFilePathForWebUI(filePath)
952989
ctx.Data["AfterCommitID"] = commitID

services/gitdiff/gitdiff.go

Lines changed: 123 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,15 @@ const (
8181

8282
// DiffLine represents a line difference in a DiffSection.
8383
type DiffLine struct {
84-
LeftIdx int // line number, 1-based
85-
RightIdx int // line number, 1-based
86-
Match int // the diff matched index. -1: no match. 0: plain and no need to match. >0: for add/del, "Lines" slice index of the other side
87-
Type DiffLineType
88-
Content string
89-
Comments issues_model.CommentList // related PR code comments
90-
SectionInfo *DiffLineSectionInfo
84+
LeftIdx int // line number, 1-based
85+
RightIdx int // line number, 1-based
86+
Match int // the diff matched index. -1: no match. 0: plain and no need to match. >0: for add/del, "Lines" slice index of the other side
87+
Type DiffLineType
88+
Content string
89+
Comments issues_model.CommentList // related PR code comments
90+
SectionInfo *DiffLineSectionInfo
91+
HasHiddenComments bool // indicates if this expand button has comments in hidden lines
92+
HiddenCommentCount int // number of hidden comments in this section
9193
}
9294

9395
// DiffLineSectionInfo represents diff line section meta data
@@ -485,6 +487,25 @@ func (diff *Diff) LoadComments(ctx context.Context, issue *issues_model.Issue, c
485487
sort.SliceStable(line.Comments, func(i, j int) bool {
486488
return line.Comments[i].CreatedUnix < line.Comments[j].CreatedUnix
487489
})
490+
491+
// Mark expand buttons that have comments in hidden lines
492+
if line.Type == DiffLineSection && line.SectionInfo != nil {
493+
hiddenCommentCount := 0
494+
// Check if there are comments in the hidden range
495+
for commentLineNum := range lineCommits {
496+
absLineNum := int(commentLineNum)
497+
if commentLineNum < 0 {
498+
absLineNum = int(-commentLineNum)
499+
}
500+
if absLineNum > line.SectionInfo.LastRightIdx && absLineNum < line.SectionInfo.RightIdx {
501+
hiddenCommentCount++
502+
}
503+
}
504+
if hiddenCommentCount > 0 {
505+
line.HasHiddenComments = true
506+
line.HiddenCommentCount = hiddenCommentCount
507+
}
508+
}
488509
}
489510
}
490511
}
@@ -1370,19 +1391,105 @@ outer:
13701391

13711392
// CommentAsDiff returns c.Patch as *Diff
13721393
func CommentAsDiff(ctx context.Context, c *issues_model.Comment) (*Diff, error) {
1373-
diff, err := ParsePatch(ctx, setting.Git.MaxGitDiffLines,
1374-
setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, strings.NewReader(c.Patch), "")
1394+
// Try to parse existing patch first
1395+
if c.Patch != "" {
1396+
diff, err := ParsePatch(ctx, setting.Git.MaxGitDiffLines,
1397+
setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, strings.NewReader(c.Patch), "")
1398+
if err == nil && len(diff.Files) > 0 && len(diff.Files[0].Sections) > 0 {
1399+
return diff, nil
1400+
}
1401+
}
1402+
1403+
// If patch is empty or invalid, generate code context for unchanged line comments
1404+
if c.TreePath != "" && c.CommitSHA != "" && c.Line != 0 {
1405+
return generateCodeContextForComment(ctx, c)
1406+
}
1407+
1408+
return nil, fmt.Errorf("no valid patch or context available for comment ID: %d", c.ID)
1409+
}
1410+
1411+
func generateCodeContextForComment(ctx context.Context, c *issues_model.Comment) (*Diff, error) {
1412+
if err := c.LoadIssue(ctx); err != nil {
1413+
return nil, fmt.Errorf("LoadIssue: %w", err)
1414+
}
1415+
if err := c.Issue.LoadRepo(ctx); err != nil {
1416+
return nil, fmt.Errorf("LoadRepo: %w", err)
1417+
}
1418+
if err := c.Issue.LoadPullRequest(ctx); err != nil {
1419+
return nil, fmt.Errorf("LoadPullRequest: %w", err)
1420+
}
1421+
1422+
pr := c.Issue.PullRequest
1423+
if err := pr.LoadBaseRepo(ctx); err != nil {
1424+
return nil, fmt.Errorf("LoadBaseRepo: %w", err)
1425+
}
1426+
1427+
gitRepo, closer, err := gitrepo.RepositoryFromContextOrOpen(ctx, pr.BaseRepo)
13751428
if err != nil {
1376-
log.Error("Unable to parse patch: %v", err)
1377-
return nil, err
1429+
return nil, fmt.Errorf("RepositoryFromContextOrOpen: %w", err)
1430+
}
1431+
defer closer.Close()
1432+
1433+
// Get the file content at the commit
1434+
commit, err := gitRepo.GetCommit(c.CommitSHA)
1435+
if err != nil {
1436+
return nil, fmt.Errorf("GetCommit: %w", err)
13781437
}
1379-
if len(diff.Files) == 0 {
1380-
return nil, fmt.Errorf("no file found for comment ID: %d", c.ID)
1438+
1439+
entry, err := commit.GetTreeEntryByPath(c.TreePath)
1440+
if err != nil {
1441+
return nil, fmt.Errorf("GetTreeEntryByPath: %w", err)
13811442
}
1382-
secs := diff.Files[0].Sections
1383-
if len(secs) == 0 {
1384-
return nil, fmt.Errorf("no sections found for comment ID: %d", c.ID)
1443+
1444+
blob := entry.Blob()
1445+
dataRc, err := blob.DataAsync()
1446+
if err != nil {
1447+
return nil, fmt.Errorf("DataAsync: %w", err)
1448+
}
1449+
defer dataRc.Close()
1450+
1451+
// Read file lines
1452+
scanner := bufio.NewScanner(dataRc)
1453+
var lines []string
1454+
for scanner.Scan() {
1455+
lines = append(lines, scanner.Text())
1456+
}
1457+
if err := scanner.Err(); err != nil {
1458+
return nil, fmt.Errorf("scanner error: %w", err)
1459+
}
1460+
1461+
// Validate comment line is within file bounds
1462+
commentLine := int(c.UnsignedLine())
1463+
if commentLine < 1 || commentLine > len(lines) {
1464+
return nil, fmt.Errorf("comment line %d is out of file bounds (1-%d)", commentLine, len(lines))
13851465
}
1466+
1467+
// Calculate line range to show (commented line + lines above it, matching CutDiffAroundLine behavior)
1468+
contextLines := setting.UI.CodeCommentLines
1469+
startLine := commentLine - contextLines
1470+
if startLine < 1 {
1471+
startLine = 1
1472+
}
1473+
endLine := commentLine
1474+
1475+
var patchBuilder strings.Builder
1476+
patchBuilder.WriteString(fmt.Sprintf("diff --git a/%s b/%s\n", c.TreePath, c.TreePath))
1477+
patchBuilder.WriteString(fmt.Sprintf("--- a/%s\n", c.TreePath))
1478+
patchBuilder.WriteString(fmt.Sprintf("+++ b/%s\n", c.TreePath))
1479+
patchBuilder.WriteString(fmt.Sprintf("@@ -%d,%d +%d,%d @@\n", startLine, endLine-startLine+1, startLine, endLine-startLine+1))
1480+
1481+
for i := startLine - 1; i < endLine; i++ {
1482+
patchBuilder.WriteString(" ")
1483+
patchBuilder.WriteString(lines[i])
1484+
patchBuilder.WriteString("\n")
1485+
}
1486+
1487+
diff, err := ParsePatch(ctx, setting.Git.MaxGitDiffLines,
1488+
setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, strings.NewReader(patchBuilder.String()), "")
1489+
if err != nil {
1490+
return nil, fmt.Errorf("ParsePatch: %w", err)
1491+
}
1492+
13861493
return diff, nil
13871494
}
13881495

templates/repo/diff/blob_excerpt.tmpl

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
{{$blobExcerptLink := print $.RepoLink (Iif $.PageIsWiki "/wiki" "") "/blob_excerpt/" (PathEscape $.AfterCommitID) (QueryBuild "?" "anchor" $.Anchor)}}
1+
{{$blobExcerptLink := print $.RepoLink (Iif $.PageIsWiki "/wiki" "") "/blob_excerpt/" (PathEscape $.AfterCommitID) "?" (Iif $.PageIsPullFiles (print "is_pull=true&issue_index=" $.IssueIndex "&") "")}}
22
{{if $.IsSplitStyle}}
33
{{range $k, $line := $.section.Lines}}
4-
<tr class="{{.GetHTMLDiffLineType}}-code nl-{{$k}} ol-{{$k}} line-expanded">
4+
<tr class="{{.GetHTMLDiffLineType}}-code nl-{{$k}} ol-{{$k}} line-expanded" data-line-type="{{.GetHTMLDiffLineType}}">
55
{{if eq .GetType 4}}
66
{{$expandDirection := $line.GetExpandDirection}}
77
<td class="lines-num lines-num-old" data-line-num="{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}">
@@ -33,6 +33,11 @@
3333
<td class="lines-escape lines-escape-old">{{if and $line.LeftIdx $inlineDiff.EscapeStatus.Escaped}}<button class="toggle-escape-button btn interact-bg" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff}}"></button>{{end}}</td>
3434
<td class="lines-type-marker lines-type-marker-old">{{if $line.LeftIdx}}<span class="tw-font-mono" data-type-marker=""></span>{{end}}</td>
3535
<td class="lines-code lines-code-old">
36+
{{- if and $.SignedUserID $.PageIsPullFiles $line.LeftIdx -}}
37+
<button type="button" aria-label="{{ctx.Locale.Tr "repo.diff.comment.add_line_comment"}}" class="ui primary button add-code-comment add-code-comment-left{{if (not $line.CanComment)}} tw-invisible{{end}}" data-side="left" data-idx="{{$line.LeftIdx}}">
38+
{{- svg "octicon-plus" -}}
39+
</button>
40+
{{- end -}}
3641
{{- if $line.LeftIdx -}}
3742
{{- template "repo/diff/section_code" dict "diff" $inlineDiff -}}
3843
{{- else -}}
@@ -43,6 +48,11 @@
4348
<td class="lines-escape lines-escape-new">{{if and $line.RightIdx $inlineDiff.EscapeStatus.Escaped}}<button class="toggle-escape-button btn interact-bg" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff}}"></button>{{end}}</td>
4449
<td class="lines-type-marker lines-type-marker-new">{{if $line.RightIdx}}<span class="tw-font-mono" data-type-marker=""></span>{{end}}</td>
4550
<td class="lines-code lines-code-new">
51+
{{- if and $.SignedUserID $.PageIsPullFiles $line.RightIdx -}}
52+
<button type="button" aria-label="{{ctx.Locale.Tr "repo.diff.comment.add_line_comment"}}" class="ui primary button add-code-comment add-code-comment-right{{if (not $line.CanComment)}} tw-invisible{{end}}" data-side="right" data-idx="{{$line.RightIdx}}">
53+
{{- svg "octicon-plus" -}}
54+
</button>
55+
{{- end -}}
4656
{{- if $line.RightIdx -}}
4757
{{- template "repo/diff/section_code" dict "diff" $inlineDiff -}}
4858
{{- else -}}
@@ -51,10 +61,24 @@
5161
</td>
5262
{{end}}
5363
</tr>
64+
{{if $line.Comments}}
65+
<tr class="add-comment" data-line-type="{{.GetHTMLDiffLineType}}">
66+
<td class="add-comment-left" colspan="4">
67+
{{if eq $line.GetCommentSide "previous"}}
68+
{{template "repo/diff/conversation" dict "." $ "comments" $line.Comments}}
69+
{{end}}
70+
</td>
71+
<td class="add-comment-right" colspan="4">
72+
{{if eq $line.GetCommentSide "proposed"}}
73+
{{template "repo/diff/conversation" dict "." $ "comments" $line.Comments}}
74+
{{end}}
75+
</td>
76+
</tr>
77+
{{end}}
5478
{{end}}
5579
{{else}}
5680
{{range $k, $line := $.section.Lines}}
57-
<tr class="{{.GetHTMLDiffLineType}}-code nl-{{$k}} ol-{{$k}} line-expanded">
81+
<tr class="{{.GetHTMLDiffLineType}}-code nl-{{$k}} ol-{{$k}} line-expanded" data-line-type="{{.GetHTMLDiffLineType}}">
5882
{{if eq .GetType 4}}
5983
{{$expandDirection := $line.GetExpandDirection}}
6084
<td colspan="2" class="lines-num">
@@ -83,7 +107,21 @@
83107
{{$inlineDiff := $.section.GetComputedInlineDiffFor $line ctx.Locale}}
84108
<td class="lines-escape">{{if $inlineDiff.EscapeStatus.Escaped}}<button class="toggle-escape-button btn interact-bg" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff}}"></button>{{end}}</td>
85109
<td class="lines-type-marker"><span class="tw-font-mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span></td>
86-
<td class="lines-code{{if (not $line.RightIdx)}} lines-code-old{{end}}"><code {{if $inlineDiff.EscapeStatus.Escaped}}class="code-inner has-escaped" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff}}"{{else}}class="code-inner"{{end}}>{{$inlineDiff.Content}}</code></td>
110+
<td class="lines-code{{if (not $line.RightIdx)}} lines-code-old{{end}}">
111+
{{- if and $.SignedUserID $.PageIsPullFiles -}}
112+
<button type="button" aria-label="{{ctx.Locale.Tr "repo.diff.comment.add_line_comment"}}" class="ui primary button add-code-comment add-code-comment-{{if $line.RightIdx}}right{{else}}left{{end}}{{if (not $line.CanComment)}} tw-invisible{{end}}" data-side="{{if $line.RightIdx}}right{{else}}left{{end}}" data-idx="{{if $line.RightIdx}}{{$line.RightIdx}}{{else}}{{$line.LeftIdx}}{{end}}">
113+
{{- svg "octicon-plus" -}}
114+
</button>
115+
{{- end -}}
116+
<code {{if $inlineDiff.EscapeStatus.Escaped}}class="code-inner has-escaped" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff}}"{{else}}class="code-inner"{{end}}>{{$inlineDiff.Content}}</code>
117+
</td>
87118
</tr>
119+
{{if $line.Comments}}
120+
<tr class="add-comment" data-line-type="{{.GetHTMLDiffLineType}}">
121+
<td class="add-comment-left add-comment-right" colspan="5">
122+
{{template "repo/diff/conversation" dict "." $ "comments" $line.Comments}}
123+
</td>
124+
</tr>
125+
{{end}}
88126
{{end}}
89127
{{end}}

templates/repo/diff/section_split.tmpl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{$file := .file}}
2-
{{$blobExcerptLink := print (or ctx.RootData.CommitRepoLink ctx.RootData.RepoLink) (Iif $.root.PageIsWiki "/wiki" "") "/blob_excerpt/" (PathEscape $.root.AfterCommitID) "?"}}
2+
{{$blobExcerptLink := print (or ctx.RootData.CommitRepoLink ctx.RootData.RepoLink) (Iif $.root.PageIsWiki "/wiki" "") "/blob_excerpt/" (PathEscape $.root.AfterCommitID) "?" (Iif $.root.PageIsPullFiles (print "is_pull=true&issue_index=" $.root.Issue.Index "&") "")}}
33
<colgroup>
44
<col width="50">
55
<col width="10">
@@ -20,18 +20,21 @@
2020
<td class="lines-num lines-num-old">
2121
<div class="code-expander-buttons" data-expand-direction="{{$expandDirection}}">
2222
{{if or (eq $expandDirection 3) (eq $expandDirection 5)}}
23-
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$blobExcerptLink}}&{{$line.GetBlobExcerptQuery}}&style=split&direction=down&&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
23+
<button class="code-expander-button{{if $line.HasHiddenComments}} has-hidden-comments{{end}}" hx-target="closest tr" hx-get="{{$blobExcerptLink}}&{{$line.GetBlobExcerptQuery}}&style=split&direction=down&&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}" title="{{if $line.HasHiddenComments}}{{$line.HiddenCommentCount}} hidden comment(s){{end}}">
2424
{{svg "octicon-fold-down"}}
25+
{{if $line.HasHiddenComments}}<span class="ui mini label">{{$line.HiddenCommentCount}}</span>{{end}}
2526
</button>
2627
{{end}}
2728
{{if or (eq $expandDirection 3) (eq $expandDirection 4)}}
28-
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$blobExcerptLink}}&{{$line.GetBlobExcerptQuery}}&style=split&direction=up&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
29+
<button class="code-expander-button{{if $line.HasHiddenComments}} has-hidden-comments{{end}}" hx-target="closest tr" hx-get="{{$blobExcerptLink}}&{{$line.GetBlobExcerptQuery}}&style=split&direction=up&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}" title="{{if $line.HasHiddenComments}}{{$line.HiddenCommentCount}} hidden comment(s){{end}}">
2930
{{svg "octicon-fold-up"}}
31+
{{if $line.HasHiddenComments}}<span class="ui mini label">{{$line.HiddenCommentCount}}</span>{{end}}
3032
</button>
3133
{{end}}
3234
{{if eq $expandDirection 2}}
33-
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$blobExcerptLink}}&{{$line.GetBlobExcerptQuery}}&style=split&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
35+
<button class="code-expander-button{{if $line.HasHiddenComments}} has-hidden-comments{{end}}" hx-target="closest tr" hx-get="{{$blobExcerptLink}}&{{$line.GetBlobExcerptQuery}}&style=split&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}" title="{{if $line.HasHiddenComments}}{{$line.HiddenCommentCount}} hidden comment(s){{end}}">
3436
{{svg "octicon-fold"}}
37+
{{if $line.HasHiddenComments}}<span class="ui mini label">{{$line.HiddenCommentCount}}</span>{{end}}
3538
</button>
3639
{{end}}
3740
</div>

templates/repo/diff/section_unified.tmpl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{$file := .file}}
22
{{$repoLink := or ctx.RootData.CommitRepoLink ctx.RootData.RepoLink}}
33
{{$afterCommitID := or $.root.AfterCommitID "no-after-commit-id"}}{{/* this tmpl is also used by the PR Conversation page, so the "AfterCommitID" may not exist */}}
4-
{{$blobExcerptLink := print $repoLink (Iif $.root.PageIsWiki "/wiki" "") "/blob_excerpt/" (PathEscape $afterCommitID) "?"}}
4+
{{$blobExcerptLink := print $repoLink (Iif $.root.PageIsWiki "/wiki" "") "/blob_excerpt/" (PathEscape $afterCommitID) "?" (Iif $.root.PageIsPullFiles (print "is_pull=true&issue_index=" $.root.Issue.Index "&") "")}}
55
<colgroup>
66
<col width="50">
77
<col width="50">
@@ -18,18 +18,21 @@
1818
<td colspan="2" class="lines-num">
1919
<div class="code-expander-buttons" data-expand-direction="{{$expandDirection}}">
2020
{{if or (eq $expandDirection 3) (eq $expandDirection 5)}}
21-
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$blobExcerptLink}}&{{$line.GetBlobExcerptQuery}}&style=unified&direction=down&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
21+
<button class="code-expander-button{{if $line.HasHiddenComments}} has-hidden-comments{{end}}" hx-target="closest tr" hx-get="{{$blobExcerptLink}}&{{$line.GetBlobExcerptQuery}}&style=unified&direction=down&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}" title="{{if $line.HasHiddenComments}}{{$line.HiddenCommentCount}} hidden comment(s){{end}}">
2222
{{svg "octicon-fold-down"}}
23+
{{if $line.HasHiddenComments}}<span class="ui mini label">{{$line.HiddenCommentCount}}</span>{{end}}
2324
</button>
2425
{{end}}
2526
{{if or (eq $expandDirection 3) (eq $expandDirection 4)}}
26-
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$blobExcerptLink}}&{{$line.GetBlobExcerptQuery}}&style=unified&direction=up&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
27+
<button class="code-expander-button{{if $line.HasHiddenComments}} has-hidden-comments{{end}}" hx-target="closest tr" hx-get="{{$blobExcerptLink}}&{{$line.GetBlobExcerptQuery}}&style=unified&direction=up&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}" title="{{if $line.HasHiddenComments}}{{$line.HiddenCommentCount}} hidden comment(s){{end}}">
2728
{{svg "octicon-fold-up"}}
29+
{{if $line.HasHiddenComments}}<span class="ui mini label">{{$line.HiddenCommentCount}}</span>{{end}}
2830
</button>
2931
{{end}}
3032
{{if eq $expandDirection 2}}
31-
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$blobExcerptLink}}&{{$line.GetBlobExcerptQuery}}&style=unified&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
33+
<button class="code-expander-button{{if $line.HasHiddenComments}} has-hidden-comments{{end}}" hx-target="closest tr" hx-get="{{$blobExcerptLink}}&{{$line.GetBlobExcerptQuery}}&style=unified&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}" title="{{if $line.HasHiddenComments}}{{$line.HiddenCommentCount}} hidden comment(s){{end}}">
3234
{{svg "octicon-fold"}}
35+
{{if $line.HasHiddenComments}}<span class="ui mini label">{{$line.HiddenCommentCount}}</span>{{end}}
3336
</button>
3437
{{end}}
3538
</div>

web_src/css/index.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
@import "./repo/clone.css";
7272
@import "./repo/commit-sign.css";
7373
@import "./repo/packages.css";
74+
@import "./repo/diff-hidden-comments.css";
7475

7576
@import "./editor/fileeditor.css";
7677
@import "./editor/combomarkdowneditor.css";

0 commit comments

Comments
 (0)