(c *ContextCommon)
| 25 | ) |
| 26 | |
| 27 | func NewCommitFilesContext(c *ContextCommon) *CommitFilesContext { |
| 28 | viewModel := filetree.NewCommitFileTreeViewModel( |
| 29 | func() []*models.CommitFile { return c.Model().CommitFiles }, |
| 30 | c.Common, |
| 31 | c.UserConfig().Gui.ShowFileTree, |
| 32 | ) |
| 33 | |
| 34 | getDisplayStrings := func(_ int, _ int) [][]string { |
| 35 | if viewModel.Len() == 0 { |
| 36 | return [][]string{{style.FgRed.Sprint("(none)")}} |
| 37 | } |
| 38 | |
| 39 | showFileIcons := icons.IsIconEnabled() && c.UserConfig().Gui.ShowFileIcons |
| 40 | lines := presentation.RenderCommitFileTree(viewModel, c.Git().Patch.PatchBuilder, showFileIcons, &c.UserConfig().Gui.CustomIcons) |
| 41 | return lo.Map(lines, func(line string, _ int) []string { |
| 42 | return []string{line} |
| 43 | }) |
| 44 | } |
| 45 | |
| 46 | ctx := &CommitFilesContext{ |
| 47 | CommitFileTreeViewModel: viewModel, |
| 48 | DynamicTitleBuilder: NewDynamicTitleBuilder(c.Tr.CommitFilesDynamicTitle), |
| 49 | ListContextTrait: &ListContextTrait{ |
| 50 | Context: NewSimpleContext( |
| 51 | NewBaseContext(NewBaseContextOpts{ |
| 52 | View: c.Views().CommitFiles, |
| 53 | WindowName: "commits", |
| 54 | Key: COMMIT_FILES_CONTEXT_KEY, |
| 55 | Kind: types.SIDE_CONTEXT, |
| 56 | Focusable: true, |
| 57 | Transient: true, |
| 58 | }), |
| 59 | ), |
| 60 | ListRenderer: ListRenderer{ |
| 61 | list: viewModel, |
| 62 | getDisplayStrings: getDisplayStrings, |
| 63 | }, |
| 64 | c: c, |
| 65 | }, |
| 66 | } |
| 67 | |
| 68 | return ctx |
| 69 | } |
| 70 | |
| 71 | func (self *CommitFilesContext) GetDiffTerminals() []string { |
| 72 | return []string{self.GetRef().RefName()} |
no test coverage detected