fix: full file highlighting for git diff with CR char (#38484)

fix #38481
This commit is contained in:
wxiaoguang authored and GitHub committed 2026-07-16 11:36:46 +00:00
1 parent f15868d442
commit 875b2e8def
2 files changed
+20 -1

No files matched your search

+13
View File
@@ -1143,6 +1143,19 @@ func TestHighlightCodeLines(t *testing.T) {
1: `<span class="n">b</span>` + nl,
}, ret)
})
t.Run("CharCR", func(t *testing.T) {
diffFile := &DiffFile{
Name: "a.txt",
Sections: []*DiffSection{
{
Lines: []*DiffLine{{LeftIdx: 1}, {LeftIdx: 2}},
},
},
}
ret := highlightCodeLinesForDiffFile(diffFile, true, []byte("a\rb\r\nc"))
assert.Equal(t, "a␍b\n", string(ret[0]))
assert.Equal(t, `c`, string(ret[1]))
})
}
func TestSyncUserSpecificDiff_UpdatedFiles(t *testing.T) {