Skip to content

Commit 0eaefbc

Browse files
committed
- removing filename and language from diffWithHighlight func
1 parent 843cb3d commit 0eaefbc

File tree

3 files changed

+3
-12
lines changed

3 files changed

+3
-12
lines changed

services/gitdiff/gitdiff.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,6 @@ func (diffSection *DiffSection) GetComputedInlineDiffFor(diffLine *DiffLine, loc
301301
diff2 string
302302
)
303303

304-
language := ""
305-
if diffSection.file != nil {
306-
language = diffSection.file.Language
307-
}
308304
// try to find equivalent diff line. ignore, otherwise
309305
switch diffLine.Type {
310306
case DiffLineSection:
@@ -335,10 +331,10 @@ func (diffSection *DiffSection) GetComputedInlineDiffFor(diffLine *DiffLine, loc
335331
}
336332

337333
hcd := newHighlightCodeDiff()
338-
diffRecord := hcd.diffWithHighlight(diffSection.FileName, language, diff1, diff2)
334+
diffRecord := hcd.diffWithHighlight(diff1, diff2)
339335
// it seems that Gitea doesn't need the line wrapper of Chroma, so do not add them back
340336
// if the line wrappers are still needed in the future, it can be added back by "diffToHTML(hcd.lineWrapperTags. ...)"
341-
diffHTML := html.UnescapeString(diffToHTML(nil, diffRecord, diffLine.Type))
337+
diffHTML := diffToHTML(nil, diffRecord, diffLine.Type)
342338
return DiffInlineWithUnicodeEscape(template.HTML(diffHTML), locale)
343339
}
344340

services/gitdiff/highlightdiff.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func (hcd *highlightCodeDiff) collectUsedRunes(code string) {
8484
}
8585
}
8686

87-
func (hcd *highlightCodeDiff) diffWithHighlight(filename, language, codeA, codeB string) []diffmatchpatch.Diff {
87+
func (hcd *highlightCodeDiff) diffWithHighlight(codeA, codeB string) []diffmatchpatch.Diff {
8888
hcd.collectUsedRunes(codeA)
8989
hcd.collectUsedRunes(codeB)
9090

services/gitdiff/highlightdiff_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
func TestDiffWithHighlight(t *testing.T) {
1515
hcd := newHighlightCodeDiff()
1616
diffs := hcd.diffWithHighlight(
17-
"main.v", "",
1817
" run('<>')\n",
1918
" run(db)\n",
2019
)
@@ -42,7 +41,6 @@ func TestDiffWithHighlight(t *testing.T) {
4241
func TestDiffWithHighlightPlaceholder(t *testing.T) {
4342
hcd := newHighlightCodeDiff()
4443
diffs := hcd.diffWithHighlight(
45-
"main.js", "",
4644
"a='\U00100000'",
4745
"a='\U0010FFFD''",
4846
)
@@ -55,7 +53,6 @@ func TestDiffWithHighlightPlaceholder(t *testing.T) {
5553

5654
hcd = newHighlightCodeDiff()
5755
diffs = hcd.diffWithHighlight(
58-
"main.js", "",
5956
"a='\U00100000'",
6057
"a='\U0010FFFD'",
6158
)
@@ -68,7 +65,6 @@ func TestDiffWithHighlightPlaceholderExhausted(t *testing.T) {
6865
hcd := newHighlightCodeDiff()
6966
hcd.placeholderMaxCount = 0
7067
diffs := hcd.diffWithHighlight(
71-
"main.js", "",
7268
"'",
7369
``,
7470
)
@@ -79,7 +75,6 @@ func TestDiffWithHighlightPlaceholderExhausted(t *testing.T) {
7975
hcd = newHighlightCodeDiff()
8076
hcd.placeholderMaxCount = 0
8177
diffs = hcd.diffWithHighlight(
82-
"main.js", "",
8378
"a < b",
8479
"a > b",
8580
)

0 commit comments

Comments
 (0)