@@ -192,9 +192,9 @@ func getDiffLineSectionInfo(treePath, line string, lastLeftIdx, lastRightIdx int
192192}
193193
194194// escape a line's content or return <br> needed for copy/paste purposes
195- func getLineContent (content string , locale translation.Locale ) DiffInline {
195+ func getLineContent (ctx context. Context , content string , locale translation.Locale ) DiffInline {
196196 if len (content ) > 0 {
197- return DiffInlineWithUnicodeEscape (template .HTML (html .EscapeString (content )), locale )
197+ return DiffInlineWithUnicodeEscape (ctx , template .HTML (html .EscapeString (content )), locale )
198198 }
199199 return DiffInline {EscapeStatus : & charset.EscapeStatus {}, Content : "<br>" }
200200}
@@ -271,8 +271,8 @@ type DiffInline struct {
271271}
272272
273273// DiffInlineWithUnicodeEscape makes a DiffInline with hidden Unicode characters escaped
274- func DiffInlineWithUnicodeEscape (s template.HTML , locale translation.Locale ) DiffInline {
275- status , content := charset .EscapeControlHTML (s , locale )
274+ func DiffInlineWithUnicodeEscape (ctx context. Context , s template.HTML , locale translation.Locale ) DiffInline {
275+ status , content := charset .EscapeControlHTML (ctx , s , locale )
276276 return DiffInline {EscapeStatus : status , Content : content }
277277}
278278
@@ -291,7 +291,7 @@ func (diffSection *DiffSection) getLineContentForRender(lineIdx int, diffLine *D
291291 return h
292292}
293293
294- func (diffSection * DiffSection ) getDiffLineForRender (diffLineType DiffLineType , leftLine , rightLine * DiffLine , locale translation.Locale ) DiffInline {
294+ func (diffSection * DiffSection ) getDiffLineForRender (ctx context. Context , diffLineType DiffLineType , leftLine , rightLine * DiffLine , locale translation.Locale ) DiffInline {
295295 var fileLanguage string
296296 var highlightedLeftLines , highlightedRightLines map [int ]template.HTML
297297 // when a "diff section" is manually prepared by ExcerptBlob, it doesn't have "file" information
@@ -326,25 +326,25 @@ func (diffSection *DiffSection) getDiffLineForRender(diffLineType DiffLineType,
326326 lineHTML = util .Iif (diffLineType == DiffLineDel , diff1 , diff2 )
327327 }
328328 }
329- return DiffInlineWithUnicodeEscape (lineHTML , locale )
329+ return DiffInlineWithUnicodeEscape (ctx , lineHTML , locale )
330330}
331331
332332// GetComputedInlineDiffFor computes inline diff for the given line.
333- func (diffSection * DiffSection ) GetComputedInlineDiffFor (diffLine * DiffLine , locale translation.Locale ) DiffInline {
333+ func (diffSection * DiffSection ) GetComputedInlineDiffFor (ctx context. Context , diffLine * DiffLine , locale translation.Locale ) DiffInline {
334334 // try to find equivalent diff line. ignore, otherwise
335335 switch diffLine .Type {
336336 case DiffLineSection :
337- return getLineContent (diffLine .Content [1 :], locale )
337+ return getLineContent (ctx , diffLine .Content [1 :], locale )
338338 case DiffLineAdd :
339339 compareDiffLine := diffSection .GetLine (diffLine .Match )
340- return diffSection .getDiffLineForRender (DiffLineAdd , compareDiffLine , diffLine , locale )
340+ return diffSection .getDiffLineForRender (ctx , DiffLineAdd , compareDiffLine , diffLine , locale )
341341 case DiffLineDel :
342342 compareDiffLine := diffSection .GetLine (diffLine .Match )
343- return diffSection .getDiffLineForRender (DiffLineDel , diffLine , compareDiffLine , locale )
343+ return diffSection .getDiffLineForRender (ctx , DiffLineDel , diffLine , compareDiffLine , locale )
344344 default : // Plain
345345 // TODO: there was an "if" check: `if diffLine.Content >strings.IndexByte(" +-", diffLine.Content[0]) > -1 { ... } else { ... }`
346346 // no idea why it needs that check, it seems that the "if" should be always true, so try to simplify the code
347- return diffSection .getDiffLineForRender (DiffLinePlain , nil , diffLine , locale )
347+ return diffSection .getDiffLineForRender (ctx , DiffLinePlain , nil , diffLine , locale )
348348 }
349349}
350350
0 commit comments