MCPcopy Index your code
hub / github.com/jesseduffield/lazygit / NewCommitFilesContext

Function NewCommitFilesContext

pkg/gui/context/commit_files_context.go:27–69  ·  view source on GitHub ↗
(c *ContextCommon)

Source from the content-addressed store, hash-verified

25)
26
27func 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
71func (self *CommitFilesContext) GetDiffTerminals() []string {
72 return []string{self.GetRef().RefName()}

Callers 1

NewContextTreeFunction · 0.85

Calls 12

IsIconEnabledFunction · 0.92
RenderCommitFileTreeFunction · 0.92
NewDynamicTitleBuilderFunction · 0.85
NewSimpleContextFunction · 0.85
NewBaseContextFunction · 0.85
UserConfigMethod · 0.80
ModelMethod · 0.65
LenMethod · 0.65
SprintMethod · 0.65
GitMethod · 0.65
ViewsMethod · 0.65

Tested by

no test coverage detected