()
| 116 | } |
| 117 | |
| 118 | func (m LogModel) loadCommitDiff() tea.Cmd { |
| 119 | commit := m.commits[m.cursor] |
| 120 | repo := m.repo |
| 121 | styles := m.styles |
| 122 | t := m.theme |
| 123 | width := m.width |
| 124 | |
| 125 | return func() tea.Msg { |
| 126 | raw, err := repo.CommitDiff(commit.Hash) |
| 127 | if err != nil { |
| 128 | return logDiffLoadedMsg{content: "Error: " + err.Error(), hash: commit.Hash} |
| 129 | } |
| 130 | // Guess filename from diff headers for syntax highlighting |
| 131 | content := renderCommitDiff(raw, styles, t, width) |
| 132 | return logDiffLoadedMsg{content: content, hash: commit.Hash} |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | // renderCommitDiff renders a full commit diff (may contain multiple files). |
| 137 | func renderCommitDiff(raw string, styles Styles, t theme.Theme, width int) string { |
no test coverage detected