File tree Expand file tree Collapse file tree 5 files changed +25
-16
lines changed
Expand file tree Collapse file tree 5 files changed +25
-16
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ type ListContextTrait struct {
1414 list types.IList
1515 getDisplayStrings func (startIdx int , length int ) [][]string
1616 // Alignment for each column. If nil, the default is left alignment
17- columnAlignments []utils.Alignment
17+ getColumnAlignments func () []utils.Alignment
1818 // Some contexts, like the commit context, will highlight the path from the selected commit
1919 // to its parents, because it's ambiguous otherwise. For these, we need to refresh the viewport
2020 // so that we show the highlighted path.
@@ -82,9 +82,13 @@ func (self *ListContextTrait) HandleFocusLost(opts types.OnFocusLostOpts) error
8282// OnFocus assumes that the content of the context has already been rendered to the view. OnRender is the function which actually renders the content to the view
8383func (self * ListContextTrait ) HandleRender () error {
8484 self .list .RefreshSelectedIdx ()
85+ var columnAlignments []utils.Alignment
86+ if self .getColumnAlignments != nil {
87+ columnAlignments = self .getColumnAlignments ()
88+ }
8589 content := utils .RenderDisplayStrings (
8690 self .getDisplayStrings (0 , self .list .Len ()),
87- self . columnAlignments ,
91+ columnAlignments ,
8892 )
8993 self .GetViewTrait ().SetContent (content )
9094 self .c .Render ()
Original file line number Diff line number Diff line change @@ -35,10 +35,10 @@ func NewMenuContext(
3535 Focusable : true ,
3636 HasUncontrolledBounds : true ,
3737 })),
38- getDisplayStrings : viewModel .GetDisplayStrings ,
39- list : viewModel ,
40- c : c ,
41- columnAlignments : []utils.Alignment { utils . AlignRight , utils . AlignLeft },
38+ getDisplayStrings : viewModel .GetDisplayStrings ,
39+ list : viewModel ,
40+ c : c ,
41+ getColumnAlignments : func () []utils.Alignment { return viewModel . columnAlignment },
4242 },
4343 }
4444}
@@ -54,8 +54,9 @@ func (self *MenuContext) GetSelectedItemId() string {
5454}
5555
5656type MenuViewModel struct {
57- c * ContextCommon
58- menuItems []* types.MenuItem
57+ c * ContextCommon
58+ menuItems []* types.MenuItem
59+ columnAlignment []utils.Alignment
5960 * FilteredListViewModel [* types.MenuItem ]
6061}
6162
@@ -73,8 +74,9 @@ func NewMenuViewModel(c *ContextCommon) *MenuViewModel {
7374 return self
7475}
7576
76- func (self * MenuViewModel ) SetMenuItems (items []* types.MenuItem ) {
77+ func (self * MenuViewModel ) SetMenuItems (items []* types.MenuItem , columnAlignment []utils. Alignment ) {
7778 self .menuItems = items
79+ self .columnAlignment = columnAlignment
7880}
7981
8082// TODO: move into presentation package
Original file line number Diff line number Diff line change 44 "github.com/jesseduffield/generics/slices"
55 "github.com/jesseduffield/lazygit/pkg/gui/keybindings"
66 "github.com/jesseduffield/lazygit/pkg/gui/types"
7+ "github.com/jesseduffield/lazygit/pkg/utils"
78 "github.com/samber/lo"
89)
910
@@ -37,9 +38,10 @@ func (self *OptionsMenuAction) Call() error {
3738 })
3839
3940 return self .c .Menu (types.CreateMenuOptions {
40- Title : self .c .Tr .Keybindings ,
41- Items : menuItems ,
42- HideCancel : true ,
41+ Title : self .c .Tr .Keybindings ,
42+ Items : menuItems ,
43+ HideCancel : true ,
44+ ColumnAlignment : []utils.Alignment {utils .AlignRight , utils .AlignLeft },
4345 })
4446}
4547
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ func (gui *Gui) createMenu(opts types.CreateMenuOptions) error {
4141 }
4242 }
4343
44- gui .State .Contexts .Menu .SetMenuItems (opts .Items )
44+ gui .State .Contexts .Menu .SetMenuItems (opts .Items , opts . ColumnAlignment )
4545 gui .State .Contexts .Menu .SetSelectedLineIdx (0 )
4646
4747 gui .Views .Menu .Title = opts .Title
Original file line number Diff line number Diff line change @@ -133,9 +133,10 @@ type IPopupHandler interface {
133133}
134134
135135type CreateMenuOptions struct {
136- Title string
137- Items []* MenuItem
138- HideCancel bool
136+ Title string
137+ Items []* MenuItem
138+ HideCancel bool
139+ ColumnAlignment []utils.Alignment
139140}
140141
141142type CreatePopupPanelOpts struct {
You can’t perform that action at this time.
0 commit comments