mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-03-31 22:22:14 +02:00
support viewing commits of reflog entry and show better view title
This commit is contained in:
parent
e039429885
commit
13b90ac37f
@ -111,15 +111,10 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
|||||||
<kbd>enter</kbd>: view commits
|
<kbd>enter</kbd>: view commits
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
## Commit Files Panel
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
<kbd>ctrl+o</kbd>: copy the committed file name to the clipboard
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
## Commit Files Panel (Commit Files)
|
## Commit Files Panel (Commit Files)
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
|
<kbd>ctrl+o</kbd>: copy the committed file name to the clipboard
|
||||||
<kbd>c</kbd>: checkout file
|
<kbd>c</kbd>: checkout file
|
||||||
<kbd>d</kbd>: discard this commit's changes to this file
|
<kbd>d</kbd>: discard this commit's changes to this file
|
||||||
<kbd>o</kbd>: open file
|
<kbd>o</kbd>: open file
|
||||||
@ -174,7 +169,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
|||||||
<kbd>c</kbd>: copy commit (cherry-pick)
|
<kbd>c</kbd>: copy commit (cherry-pick)
|
||||||
<kbd>C</kbd>: copy commit range (cherry-pick)
|
<kbd>C</kbd>: copy commit range (cherry-pick)
|
||||||
<kbd>ctrl+r</kbd>: reset cherry-picked (copied) commits selection
|
<kbd>ctrl+r</kbd>: reset cherry-picked (copied) commits selection
|
||||||
<kbd>enter</kbd>: view selected item's files
|
<kbd>enter</kbd>: view commits
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
## Extras Panel
|
## Extras Panel
|
||||||
@ -307,3 +302,16 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
|||||||
<kbd>enter</kbd>: switch to a recent repo
|
<kbd>enter</kbd>: switch to a recent repo
|
||||||
<kbd>a</kbd>: show all branch logs
|
<kbd>a</kbd>: show all branch logs
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
## Sub-commits Panel (Sub-commits)
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
<kbd>ctrl+o</kbd>: copy commit SHA to clipboard
|
||||||
|
<kbd>space</kbd>: checkout commit
|
||||||
|
<kbd>g</kbd>: view reset options
|
||||||
|
<kbd>n</kbd>: new branch
|
||||||
|
<kbd>c</kbd>: copy commit (cherry-pick)
|
||||||
|
<kbd>C</kbd>: copy commit range (cherry-pick)
|
||||||
|
<kbd>ctrl+r</kbd>: reset cherry-picked (copied) commits selection
|
||||||
|
<kbd>enter</kbd>: view selected item's files
|
||||||
|
</pre>
|
||||||
|
@ -151,15 +151,10 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
|||||||
<kbd>enter</kbd>: bekijk commits
|
<kbd>enter</kbd>: bekijk commits
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
## Commit bestanden Paneel
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
<kbd>ctrl+o</kbd>: kopieer de vastgelegde bestandsnaam naar het klembord
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
## Commit bestanden Paneel (Commit bestanden)
|
## Commit bestanden Paneel (Commit bestanden)
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
|
<kbd>ctrl+o</kbd>: kopieer de vastgelegde bestandsnaam naar het klembord
|
||||||
<kbd>c</kbd>: bestand uitchecken
|
<kbd>c</kbd>: bestand uitchecken
|
||||||
<kbd>d</kbd>: uitsluit deze commit zijn veranderingen aan dit bestand
|
<kbd>d</kbd>: uitsluit deze commit zijn veranderingen aan dit bestand
|
||||||
<kbd>o</kbd>: open bestand
|
<kbd>o</kbd>: open bestand
|
||||||
@ -214,7 +209,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
|||||||
<kbd>c</kbd>: kopieer commit (cherry-pick)
|
<kbd>c</kbd>: kopieer commit (cherry-pick)
|
||||||
<kbd>C</kbd>: kopieer commit reeks (cherry-pick)
|
<kbd>C</kbd>: kopieer commit reeks (cherry-pick)
|
||||||
<kbd>ctrl+r</kbd>: reset cherry-picked (gekopieerde) commits selectie
|
<kbd>ctrl+r</kbd>: reset cherry-picked (gekopieerde) commits selectie
|
||||||
<kbd>enter</kbd>: bekijk gecommite bestanden
|
<kbd>enter</kbd>: bekijk commits
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
## Extras Paneel
|
## Extras Paneel
|
||||||
@ -307,3 +302,16 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
|||||||
<kbd>enter</kbd>: wissel naar een recente repo
|
<kbd>enter</kbd>: wissel naar een recente repo
|
||||||
<kbd>a</kbd>: alle logs van de branch laten zien
|
<kbd>a</kbd>: alle logs van de branch laten zien
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
## Sub-commits Paneel (Sub-commits)
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
<kbd>ctrl+o</kbd>: kopieer commit SHA naar klembord
|
||||||
|
<kbd>space</kbd>: checkout commit
|
||||||
|
<kbd>g</kbd>: bekijk reset opties
|
||||||
|
<kbd>n</kbd>: nieuwe branch
|
||||||
|
<kbd>c</kbd>: kopieer commit (cherry-pick)
|
||||||
|
<kbd>C</kbd>: kopieer commit reeks (cherry-pick)
|
||||||
|
<kbd>ctrl+r</kbd>: reset cherry-picked (gekopieerde) commits selectie
|
||||||
|
<kbd>enter</kbd>: bekijk gecommite bestanden
|
||||||
|
</pre>
|
||||||
|
@ -85,7 +85,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
|||||||
<kbd>c</kbd>: kopiuj commit (przebieranie)
|
<kbd>c</kbd>: kopiuj commit (przebieranie)
|
||||||
<kbd>C</kbd>: kopiuj zakres commitów (przebieranie)
|
<kbd>C</kbd>: kopiuj zakres commitów (przebieranie)
|
||||||
<kbd>ctrl+r</kbd>: reset cherry-picked (copied) commits selection
|
<kbd>ctrl+r</kbd>: reset cherry-picked (copied) commits selection
|
||||||
<kbd>enter</kbd>: przeglądaj pliki commita
|
<kbd>enter</kbd>: view commits
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
## Extras Panel
|
## Extras Panel
|
||||||
@ -269,15 +269,10 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
|||||||
<kbd>b</kbd>: view bulk submodule options
|
<kbd>b</kbd>: view bulk submodule options
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
## Pliki commita Panel
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
<kbd>ctrl+o</kbd>: copy the committed file name to the clipboard
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
## Pliki commita Panel (Pliki commita)
|
## Pliki commita Panel (Pliki commita)
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
|
<kbd>ctrl+o</kbd>: copy the committed file name to the clipboard
|
||||||
<kbd>c</kbd>: plik wybierania
|
<kbd>c</kbd>: plik wybierania
|
||||||
<kbd>d</kbd>: porzuć zmiany commita dla tego pliku
|
<kbd>d</kbd>: porzuć zmiany commita dla tego pliku
|
||||||
<kbd>o</kbd>: otwórz plik
|
<kbd>o</kbd>: otwórz plik
|
||||||
@ -307,3 +302,16 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
|||||||
<kbd>enter</kbd>: switch to a recent repo
|
<kbd>enter</kbd>: switch to a recent repo
|
||||||
<kbd>a</kbd>: pokaż wszystkie logi gałęzi
|
<kbd>a</kbd>: pokaż wszystkie logi gałęzi
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
## Sub-commits Panel (Sub-commits)
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
<kbd>ctrl+o</kbd>: copy commit SHA to clipboard
|
||||||
|
<kbd>space</kbd>: checkout commit
|
||||||
|
<kbd>g</kbd>: wyświetl opcje resetu
|
||||||
|
<kbd>n</kbd>: nowa gałąź
|
||||||
|
<kbd>c</kbd>: kopiuj commit (przebieranie)
|
||||||
|
<kbd>C</kbd>: kopiuj zakres commitów (przebieranie)
|
||||||
|
<kbd>ctrl+r</kbd>: reset cherry-picked (copied) commits selection
|
||||||
|
<kbd>enter</kbd>: przeglądaj pliki commita
|
||||||
|
</pre>
|
||||||
|
@ -185,6 +185,18 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
|||||||
<kbd>enter</kbd>: 查看提交的文件
|
<kbd>enter</kbd>: 查看提交的文件
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
## 提交 面板 (Reflog)
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
<kbd>ctrl+o</kbd>: 将提交的 SHA 复制到剪贴板
|
||||||
|
<kbd>space</kbd>: 检出提交
|
||||||
|
<kbd>g</kbd>: 查看重置选项
|
||||||
|
<kbd>c</kbd>: 复制提交(拣选)
|
||||||
|
<kbd>C</kbd>: 复制提交范围(拣选)
|
||||||
|
<kbd>ctrl+r</kbd>: 重置已拣选(复制)的提交
|
||||||
|
<kbd>enter</kbd>: 查看提交
|
||||||
|
</pre>
|
||||||
|
|
||||||
## 提交 面板 (提交)
|
## 提交 面板 (提交)
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
@ -217,15 +229,10 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
|||||||
<kbd>enter</kbd>: 查看提交的文件
|
<kbd>enter</kbd>: 查看提交的文件
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
## 提交文件 面板
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
<kbd>ctrl+o</kbd>: 将提交的文件名复制到剪贴板
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
## 提交文件 面板 (提交文件)
|
## 提交文件 面板 (提交文件)
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
|
<kbd>ctrl+o</kbd>: 将提交的文件名复制到剪贴板
|
||||||
<kbd>c</kbd>: 检出文件
|
<kbd>c</kbd>: 检出文件
|
||||||
<kbd>d</kbd>: 放弃对此文件的提交更改
|
<kbd>d</kbd>: 放弃对此文件的提交更改
|
||||||
<kbd>o</kbd>: 打开文件
|
<kbd>o</kbd>: 打开文件
|
||||||
|
@ -39,24 +39,20 @@ func (gui *Gui) commitFilesRenderToMain() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) SwitchToCommitFilesContext(opts controllers.SwitchToCommitFilesContextOpts) error {
|
func (gui *Gui) SwitchToCommitFilesContext(opts controllers.SwitchToCommitFilesContextOpts) error {
|
||||||
// sometimes the commitFiles view is already shown in another window, so we need to ensure that window
|
|
||||||
// no longer considers the commitFiles view as its main view.
|
|
||||||
gui.resetWindowContext(gui.State.Contexts.CommitFiles)
|
|
||||||
|
|
||||||
gui.State.Contexts.CommitFiles.SetSelectedLineIdx(0)
|
gui.State.Contexts.CommitFiles.SetSelectedLineIdx(0)
|
||||||
gui.State.Contexts.CommitFiles.SetRefName(opts.RefName)
|
gui.State.Contexts.CommitFiles.SetRefName(opts.RefName)
|
||||||
gui.State.Contexts.CommitFiles.SetCanRebase(opts.CanRebase)
|
gui.State.Contexts.CommitFiles.SetCanRebase(opts.CanRebase)
|
||||||
gui.State.Contexts.CommitFiles.SetParentContext(opts.Context)
|
gui.State.Contexts.CommitFiles.SetParentContext(opts.Context)
|
||||||
gui.State.Contexts.CommitFiles.SetWindowName(opts.Context.GetWindowName())
|
gui.State.Contexts.CommitFiles.SetWindowName(opts.Context.GetWindowName())
|
||||||
|
|
||||||
if err := gui.refreshCommitFilesView(); err != nil {
|
if err := gui.refreshCommitFilesContext(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return gui.c.PushContext(gui.State.Contexts.CommitFiles)
|
return gui.c.PushContext(gui.State.Contexts.CommitFiles)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) refreshCommitFilesView() error {
|
func (gui *Gui) refreshCommitFilesContext() error {
|
||||||
currentSideContext := gui.currentSideContext()
|
currentSideContext := gui.currentSideContext()
|
||||||
if currentSideContext.GetKey() == context.COMMIT_FILES_CONTEXT_KEY || currentSideContext.GetKey() == context.LOCAL_COMMITS_CONTEXT_KEY {
|
if currentSideContext.GetKey() == context.COMMIT_FILES_CONTEXT_KEY || currentSideContext.GetKey() == context.LOCAL_COMMITS_CONTEXT_KEY {
|
||||||
if err := gui.handleRefreshPatchBuildingPanel(-1); err != nil {
|
if err := gui.handleRefreshPatchBuildingPanel(-1); err != nil {
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/jesseduffield/gocui"
|
"github.com/jesseduffield/gocui"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||||
|
"github.com/samber/lo"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (gui *Gui) popupViewNames() []string {
|
func (gui *Gui) popupViewNames() []string {
|
||||||
@ -99,8 +100,6 @@ func (gui *Gui) pushContext(c types.Context, opts ...types.OnFocusOpts) error {
|
|||||||
return gui.activateContext(c, opts...)
|
return gui.activateContext(c, opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// asynchronous code idea: functions return an error via a channel, when done
|
|
||||||
|
|
||||||
// pushContextWithView is to be used when you don't know which context you
|
// pushContextWithView is to be used when you don't know which context you
|
||||||
// want to switch to: you only know the view that you want to switch to. It will
|
// want to switch to: you only know the view that you want to switch to. It will
|
||||||
// look up the context currently active for that view and switch to that context
|
// look up the context currently active for that view and switch to that context
|
||||||
@ -136,6 +135,10 @@ func (gui *Gui) returnFromContext() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) deactivateContext(c types.Context) error {
|
func (gui *Gui) deactivateContext(c types.Context) error {
|
||||||
|
if c.IsTransient() {
|
||||||
|
gui.resetWindowContext(c)
|
||||||
|
}
|
||||||
|
|
||||||
view, _ := gui.g.View(c.GetViewName())
|
view, _ := gui.g.View(c.GetViewName())
|
||||||
|
|
||||||
if view != nil && view.IsSearching() {
|
if view != nil && view.IsSearching() {
|
||||||
@ -145,7 +148,11 @@ func (gui *Gui) deactivateContext(c types.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if we are the kind of context that is sent to back upon deactivation, we should do that
|
// if we are the kind of context that is sent to back upon deactivation, we should do that
|
||||||
if view != nil && (c.GetKind() == types.TEMPORARY_POPUP || c.GetKind() == types.PERSISTENT_POPUP || c.GetKey() == context.COMMIT_FILES_CONTEXT_KEY) {
|
if view != nil &&
|
||||||
|
(c.GetKind() == types.TEMPORARY_POPUP ||
|
||||||
|
c.GetKind() == types.PERSISTENT_POPUP ||
|
||||||
|
c.GetKey() == context.COMMIT_FILES_CONTEXT_KEY ||
|
||||||
|
c.GetKey() == context.SUB_COMMITS_CONTEXT_KEY) {
|
||||||
view.Visible = false
|
view.Visible = false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,6 +211,11 @@ func (gui *Gui) activateContext(c types.Context, opts ...types.OnFocusOpts) erro
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
desiredTitle := c.Title()
|
||||||
|
if desiredTitle != "" {
|
||||||
|
v.Title = desiredTitle
|
||||||
|
}
|
||||||
|
|
||||||
v.Visible = true
|
v.Visible = true
|
||||||
|
|
||||||
// if the new context's view was previously displaying another context, render the new context
|
// if the new context's view was previously displaying another context, render the new context
|
||||||
@ -380,10 +392,17 @@ func (gui *Gui) onViewFocusLost(oldView *gocui.View, newView *gocui.View) error
|
|||||||
|
|
||||||
_ = oldView.SetOriginX(0)
|
_ = oldView.SetOriginX(0)
|
||||||
|
|
||||||
if oldView == gui.Views.CommitFiles && newView != gui.Views.Main && newView != gui.Views.Secondary && newView != gui.Views.Search {
|
if !lo.Contains([]*gocui.View{gui.Views.Main, gui.Views.Secondary, gui.Views.Search}, newView) {
|
||||||
gui.resetWindowContext(gui.State.Contexts.CommitFiles)
|
transientContexts := slices.Filter(gui.State.Contexts.Flatten(), func(context types.Context) bool {
|
||||||
if err := gui.deactivateContext(gui.State.Contexts.CommitFiles); err != nil {
|
return context.IsTransient()
|
||||||
return err
|
})
|
||||||
|
|
||||||
|
for _, context := range transientContexts {
|
||||||
|
if oldView.Name() == context.GetViewName() {
|
||||||
|
if err := gui.deactivateContext(context); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ type BaseContext struct {
|
|||||||
onClickFn func() error
|
onClickFn func() error
|
||||||
|
|
||||||
focusable bool
|
focusable bool
|
||||||
|
transient bool
|
||||||
|
|
||||||
*ParentContextMgr
|
*ParentContextMgr
|
||||||
}
|
}
|
||||||
@ -29,6 +30,7 @@ type NewBaseContextOpts struct {
|
|||||||
ViewName string
|
ViewName string
|
||||||
WindowName string
|
WindowName string
|
||||||
Focusable bool
|
Focusable bool
|
||||||
|
Transient bool
|
||||||
|
|
||||||
OnGetOptionsMap func() map[string]string
|
OnGetOptionsMap func() map[string]string
|
||||||
}
|
}
|
||||||
@ -41,6 +43,7 @@ func NewBaseContext(opts NewBaseContextOpts) *BaseContext {
|
|||||||
windowName: opts.WindowName,
|
windowName: opts.WindowName,
|
||||||
onGetOptionsMap: opts.OnGetOptionsMap,
|
onGetOptionsMap: opts.OnGetOptionsMap,
|
||||||
focusable: opts.Focusable,
|
focusable: opts.Focusable,
|
||||||
|
transient: opts.Transient,
|
||||||
ParentContextMgr: &ParentContextMgr{},
|
ParentContextMgr: &ParentContextMgr{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,3 +118,11 @@ func (self *BaseContext) GetMouseKeybindings(opts types.KeybindingsOpts) []*gocu
|
|||||||
func (self *BaseContext) IsFocusable() bool {
|
func (self *BaseContext) IsFocusable() bool {
|
||||||
return self.focusable
|
return self.focusable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *BaseContext) IsTransient() bool {
|
||||||
|
return self.transient
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *BaseContext) Title() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
package context
|
package context
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/jesseduffield/gocui"
|
"github.com/jesseduffield/gocui"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/filetree"
|
"github.com/jesseduffield/lazygit/pkg/gui/filetree"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CommitFilesContext struct {
|
type CommitFilesContext struct {
|
||||||
@ -37,6 +40,7 @@ func NewCommitFilesContext(
|
|||||||
Key: COMMIT_FILES_CONTEXT_KEY,
|
Key: COMMIT_FILES_CONTEXT_KEY,
|
||||||
Kind: types.SIDE_CONTEXT,
|
Kind: types.SIDE_CONTEXT,
|
||||||
Focusable: true,
|
Focusable: true,
|
||||||
|
Transient: true,
|
||||||
}),
|
}),
|
||||||
ContextCallbackOpts{
|
ContextCallbackOpts{
|
||||||
OnFocus: onFocus,
|
OnFocus: onFocus,
|
||||||
@ -59,3 +63,7 @@ func (self *CommitFilesContext) GetSelectedItemId() string {
|
|||||||
|
|
||||||
return item.ID()
|
return item.ID()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *CommitFilesContext) Title() string {
|
||||||
|
return fmt.Sprintf(self.c.Tr.CommitFilesDynamicTitle, utils.TruncateWithEllipsis(self.GetRefName(), 50))
|
||||||
|
}
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
package context
|
package context
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/jesseduffield/gocui"
|
"github.com/jesseduffield/gocui"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SubCommitsContext struct {
|
type SubCommitsContext struct {
|
||||||
*BasicViewModel[*models.Commit]
|
*SubCommitsViewModel
|
||||||
*ViewportListContextTrait
|
*ViewportListContextTrait
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,18 +27,22 @@ func NewSubCommitsContext(
|
|||||||
|
|
||||||
c *types.HelperCommon,
|
c *types.HelperCommon,
|
||||||
) *SubCommitsContext {
|
) *SubCommitsContext {
|
||||||
viewModel := NewBasicViewModel(getModel)
|
viewModel := &SubCommitsViewModel{
|
||||||
|
BasicViewModel: NewBasicViewModel(getModel),
|
||||||
|
refName: "",
|
||||||
|
}
|
||||||
|
|
||||||
return &SubCommitsContext{
|
return &SubCommitsContext{
|
||||||
BasicViewModel: viewModel,
|
SubCommitsViewModel: viewModel,
|
||||||
ViewportListContextTrait: &ViewportListContextTrait{
|
ViewportListContextTrait: &ViewportListContextTrait{
|
||||||
ListContextTrait: &ListContextTrait{
|
ListContextTrait: &ListContextTrait{
|
||||||
Context: NewSimpleContext(NewBaseContext(NewBaseContextOpts{
|
Context: NewSimpleContext(NewBaseContext(NewBaseContextOpts{
|
||||||
ViewName: "branches",
|
ViewName: "subCommits",
|
||||||
WindowName: "branches",
|
WindowName: "branches",
|
||||||
Key: SUB_COMMITS_CONTEXT_KEY,
|
Key: SUB_COMMITS_CONTEXT_KEY,
|
||||||
Kind: types.SIDE_CONTEXT,
|
Kind: types.SIDE_CONTEXT,
|
||||||
Focusable: true,
|
Focusable: true,
|
||||||
|
Transient: true,
|
||||||
}), ContextCallbackOpts{
|
}), ContextCallbackOpts{
|
||||||
OnFocus: onFocus,
|
OnFocus: onFocus,
|
||||||
OnFocusLost: onFocusLost,
|
OnFocusLost: onFocusLost,
|
||||||
@ -50,6 +57,16 @@ func NewSubCommitsContext(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SubCommitsViewModel struct {
|
||||||
|
// name of the ref that the sub-commits are shown for
|
||||||
|
refName string
|
||||||
|
*BasicViewModel[*models.Commit]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *SubCommitsViewModel) SetRefName(refName string) {
|
||||||
|
self.refName = refName
|
||||||
|
}
|
||||||
|
|
||||||
func (self *SubCommitsContext) GetSelectedItemId() string {
|
func (self *SubCommitsContext) GetSelectedItemId() string {
|
||||||
item := self.GetSelected()
|
item := self.GetSelected()
|
||||||
if item == nil {
|
if item == nil {
|
||||||
@ -63,6 +80,8 @@ func (self *SubCommitsContext) CanRebase() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// not to be confused with the refName in the view model. This is the ref name of
|
||||||
|
// the selected commit
|
||||||
func (self *SubCommitsContext) GetSelectedRefName() string {
|
func (self *SubCommitsContext) GetSelectedRefName() string {
|
||||||
item := self.GetSelected()
|
item := self.GetSelected()
|
||||||
|
|
||||||
@ -76,3 +95,7 @@ func (self *SubCommitsContext) GetSelectedRefName() string {
|
|||||||
func (self *SubCommitsContext) GetCommits() []*models.Commit {
|
func (self *SubCommitsContext) GetCommits() []*models.Commit {
|
||||||
return self.getModel()
|
return self.getModel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *SubCommitsContext) Title() string {
|
||||||
|
return fmt.Sprintf(self.c.Tr.SubCommitsDynamicTitle, utils.TruncateWithEllipsis(self.refName, 50))
|
||||||
|
}
|
||||||
|
@ -135,6 +135,7 @@ func (gui *Gui) resetControllers() {
|
|||||||
gui.State.Contexts.Branches,
|
gui.State.Contexts.Branches,
|
||||||
gui.State.Contexts.RemoteBranches,
|
gui.State.Contexts.RemoteBranches,
|
||||||
gui.State.Contexts.Tags,
|
gui.State.Contexts.Tags,
|
||||||
|
gui.State.Contexts.ReflogCommits,
|
||||||
} {
|
} {
|
||||||
controllers.AttachControllers(context, controllers.NewSwitchToSubCommitsController(
|
controllers.AttachControllers(context, controllers.NewSwitchToSubCommitsController(
|
||||||
common, setSubCommits, context,
|
common, setSubCommits, context,
|
||||||
@ -143,7 +144,6 @@ func (gui *Gui) resetControllers() {
|
|||||||
|
|
||||||
for _, context := range []controllers.CanSwitchToDiffFiles{
|
for _, context := range []controllers.CanSwitchToDiffFiles{
|
||||||
gui.State.Contexts.LocalCommits,
|
gui.State.Contexts.LocalCommits,
|
||||||
gui.State.Contexts.ReflogCommits,
|
|
||||||
gui.State.Contexts.SubCommits,
|
gui.State.Contexts.SubCommits,
|
||||||
gui.State.Contexts.Stash,
|
gui.State.Contexts.Stash,
|
||||||
} {
|
} {
|
||||||
|
@ -70,8 +70,16 @@ func (self *SwitchToSubCommitsController) viewCommits() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.setSubCommits(commits)
|
self.setSubCommits(commits)
|
||||||
|
|
||||||
self.contexts.SubCommits.SetSelectedLineIdx(0)
|
self.contexts.SubCommits.SetSelectedLineIdx(0)
|
||||||
self.contexts.SubCommits.SetParentContext(self.context)
|
self.contexts.SubCommits.SetParentContext(self.context)
|
||||||
|
self.contexts.SubCommits.SetWindowName(self.context.GetWindowName())
|
||||||
|
self.contexts.SubCommits.SetRefName(refName)
|
||||||
|
|
||||||
|
err = self.c.PostRefreshUpdate(self.contexts.SubCommits)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return self.c.PushContext(self.contexts.SubCommits)
|
return self.c.PushContext(self.contexts.SubCommits)
|
||||||
}
|
}
|
||||||
|
@ -252,6 +252,7 @@ type Views struct {
|
|||||||
Menu *gocui.View
|
Menu *gocui.View
|
||||||
CommitMessage *gocui.View
|
CommitMessage *gocui.View
|
||||||
CommitFiles *gocui.View
|
CommitFiles *gocui.View
|
||||||
|
SubCommits *gocui.View
|
||||||
Information *gocui.View
|
Information *gocui.View
|
||||||
AppStatus *gocui.View
|
AppStatus *gocui.View
|
||||||
Search *gocui.View
|
Search *gocui.View
|
||||||
@ -410,6 +411,7 @@ func initialViewContextMapping(contextTree *context.ContextTree) map[string]type
|
|||||||
"branches": contextTree.Branches,
|
"branches": contextTree.Branches,
|
||||||
"commits": contextTree.LocalCommits,
|
"commits": contextTree.LocalCommits,
|
||||||
"commitFiles": contextTree.CommitFiles,
|
"commitFiles": contextTree.CommitFiles,
|
||||||
|
"subCommits": contextTree.SubCommits,
|
||||||
"stash": contextTree.Stash,
|
"stash": contextTree.Stash,
|
||||||
"menu": contextTree.Menu,
|
"menu": contextTree.Menu,
|
||||||
"confirmation": contextTree.Confirmation,
|
"confirmation": contextTree.Confirmation,
|
||||||
@ -601,6 +603,7 @@ func (gui *Gui) createAllViews() error {
|
|||||||
{viewPtr: &gui.Views.Commits, name: "commits"},
|
{viewPtr: &gui.Views.Commits, name: "commits"},
|
||||||
{viewPtr: &gui.Views.Stash, name: "stash"},
|
{viewPtr: &gui.Views.Stash, name: "stash"},
|
||||||
{viewPtr: &gui.Views.CommitFiles, name: "commitFiles"},
|
{viewPtr: &gui.Views.CommitFiles, name: "commitFiles"},
|
||||||
|
{viewPtr: &gui.Views.SubCommits, name: "subCommits"},
|
||||||
{viewPtr: &gui.Views.Main, name: "main"},
|
{viewPtr: &gui.Views.Main, name: "main"},
|
||||||
{viewPtr: &gui.Views.Secondary, name: "secondary"},
|
{viewPtr: &gui.Views.Secondary, name: "secondary"},
|
||||||
{viewPtr: &gui.Views.Options, name: "options"},
|
{viewPtr: &gui.Views.Options, name: "options"},
|
||||||
@ -641,6 +644,8 @@ func (gui *Gui) createAllViews() error {
|
|||||||
gui.Views.CommitFiles.Title = gui.c.Tr.CommitFiles
|
gui.Views.CommitFiles.Title = gui.c.Tr.CommitFiles
|
||||||
gui.Views.CommitFiles.FgColor = theme.GocuiDefaultTextColor
|
gui.Views.CommitFiles.FgColor = theme.GocuiDefaultTextColor
|
||||||
|
|
||||||
|
gui.Views.SubCommits.FgColor = theme.GocuiDefaultTextColor
|
||||||
|
|
||||||
gui.Views.Branches.Title = gui.c.Tr.BranchesTitle
|
gui.Views.Branches.Title = gui.c.Tr.BranchesTitle
|
||||||
gui.Views.Branches.FgColor = theme.GocuiDefaultTextColor
|
gui.Views.Branches.FgColor = theme.GocuiDefaultTextColor
|
||||||
|
|
||||||
|
@ -406,7 +406,7 @@ func (self *Gui) GetInitialKeybindings() ([]*types.Binding, []*gocui.ViewMouseBi
|
|||||||
Description: self.c.Tr.LcCopyCommitShaToClipboard,
|
Description: self.c.Tr.LcCopyCommitShaToClipboard,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ViewName: "branches",
|
ViewName: "subCommits",
|
||||||
Contexts: []string{string(context.SUB_COMMITS_CONTEXT_KEY)},
|
Contexts: []string{string(context.SUB_COMMITS_CONTEXT_KEY)},
|
||||||
Key: opts.GetKey(opts.Config.Universal.CopyToClipboard),
|
Key: opts.GetKey(opts.Config.Universal.CopyToClipboard),
|
||||||
Handler: self.handleCopySelectedSideContextItemToClipboard,
|
Handler: self.handleCopySelectedSideContextItemToClipboard,
|
||||||
@ -426,6 +426,7 @@ func (self *Gui) GetInitialKeybindings() ([]*types.Binding, []*gocui.ViewMouseBi
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
ViewName: "commitFiles",
|
ViewName: "commitFiles",
|
||||||
|
Contexts: []string{string(context.COMMIT_FILES_CONTEXT_KEY)},
|
||||||
Key: opts.GetKey(opts.Config.Universal.CopyToClipboard),
|
Key: opts.GetKey(opts.Config.Universal.CopyToClipboard),
|
||||||
Handler: self.handleCopySelectedSideContextItemToClipboard,
|
Handler: self.handleCopySelectedSideContextItemToClipboard,
|
||||||
Description: self.c.Tr.LcCopyCommitFileNameToClipboard,
|
Description: self.c.Tr.LcCopyCommitFileNameToClipboard,
|
||||||
@ -998,7 +999,7 @@ func (self *Gui) GetInitialKeybindings() ([]*types.Binding, []*gocui.ViewMouseBi
|
|||||||
mouseKeybindings = append(mouseKeybindings, c.GetMouseKeybindings(opts)...)
|
mouseKeybindings = append(mouseKeybindings, c.GetMouseKeybindings(opts)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, viewName := range []string{"status", "branches", "files", "commits", "commitFiles", "stash", "menu"} {
|
for _, viewName := range []string{"status", "branches", "files", "commits", "commitFiles", "subCommits", "stash", "menu"} {
|
||||||
bindings = append(bindings, []*types.Binding{
|
bindings = append(bindings, []*types.Binding{
|
||||||
{ViewName: viewName, Key: opts.GetKey(opts.Config.Universal.PrevBlock), Modifier: gocui.ModNone, Handler: self.previousSideWindow},
|
{ViewName: viewName, Key: opts.GetKey(opts.Config.Universal.PrevBlock), Modifier: gocui.ModNone, Handler: self.previousSideWindow},
|
||||||
{ViewName: viewName, Key: opts.GetKey(opts.Config.Universal.NextBlock), Modifier: gocui.ModNone, Handler: self.nextSideWindow},
|
{ViewName: viewName, Key: opts.GetKey(opts.Config.Universal.NextBlock), Modifier: gocui.ModNone, Handler: self.nextSideWindow},
|
||||||
|
@ -2,6 +2,7 @@ package gui
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/jesseduffield/gocui"
|
"github.com/jesseduffield/gocui"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||||
"github.com/jesseduffield/lazygit/pkg/theme"
|
"github.com/jesseduffield/lazygit/pkg/theme"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -96,6 +97,7 @@ func (gui *Gui) layout(g *gocui.Gui) error {
|
|||||||
{viewName: "files", windowName: "files", frame: true},
|
{viewName: "files", windowName: "files", frame: true},
|
||||||
{viewName: "branches", windowName: "branches", frame: true},
|
{viewName: "branches", windowName: "branches", frame: true},
|
||||||
{viewName: "commitFiles", windowName: gui.State.Contexts.CommitFiles.GetWindowName(), frame: true},
|
{viewName: "commitFiles", windowName: gui.State.Contexts.CommitFiles.GetWindowName(), frame: true},
|
||||||
|
{viewName: "subCommits", windowName: gui.State.Contexts.SubCommits.GetWindowName(), frame: true},
|
||||||
{viewName: "commits", windowName: "commits", frame: true},
|
{viewName: "commits", windowName: "commits", frame: true},
|
||||||
{viewName: "stash", windowName: "stash", frame: true},
|
{viewName: "stash", windowName: "stash", frame: true},
|
||||||
{viewName: "options", windowName: "options", frame: false},
|
{viewName: "options", windowName: "options", frame: false},
|
||||||
@ -113,8 +115,13 @@ func (gui *Gui) layout(g *gocui.Gui) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the commit files view is the view to be displayed for its window, we'll display it
|
for _, context := range []types.Context{gui.State.Contexts.SubCommits, gui.State.Contexts.CommitFiles} {
|
||||||
gui.Views.CommitFiles.Visible = gui.getViewNameForWindow(gui.State.Contexts.CommitFiles.GetWindowName()) == "commitFiles"
|
view, err := gui.g.View(context.GetViewName())
|
||||||
|
if err != nil && err.Error() != UNKNOWN_VIEW_ERROR_MSG {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
view.Visible = gui.getViewNameForWindow(context.GetWindowName()) == context.GetViewName()
|
||||||
|
}
|
||||||
|
|
||||||
if gui.PrevLayout.Information != informationStr {
|
if gui.PrevLayout.Information != informationStr {
|
||||||
gui.setViewContent(gui.Views.Information, informationStr)
|
gui.setViewContent(gui.Views.Information, informationStr)
|
||||||
@ -206,6 +213,7 @@ func (gui *Gui) onInitialViewsCreation() error {
|
|||||||
gui.Views.Branches,
|
gui.Views.Branches,
|
||||||
gui.Views.Commits,
|
gui.Views.Commits,
|
||||||
gui.Views.Stash,
|
gui.Views.Stash,
|
||||||
|
gui.Views.SubCommits,
|
||||||
gui.Views.CommitFiles,
|
gui.Views.CommitFiles,
|
||||||
gui.Views.Main,
|
gui.Views.Main,
|
||||||
gui.Views.Secondary,
|
gui.Views.Secondary,
|
||||||
|
@ -141,7 +141,7 @@ func (gui *Gui) branchCommitsListContext() *context.LocalCommitsContext {
|
|||||||
func (gui *Gui) subCommitsListContext() *context.SubCommitsContext {
|
func (gui *Gui) subCommitsListContext() *context.SubCommitsContext {
|
||||||
return context.NewSubCommitsContext(
|
return context.NewSubCommitsContext(
|
||||||
func() []*models.Commit { return gui.State.Model.SubCommits },
|
func() []*models.Commit { return gui.State.Model.SubCommits },
|
||||||
gui.Views.Branches,
|
gui.Views.SubCommits,
|
||||||
func(startIdx int, length int) [][]string {
|
func(startIdx int, length int) [][]string {
|
||||||
selectedCommitSha := ""
|
selectedCommitSha := ""
|
||||||
if gui.currentContext().GetKey() == context.SUB_COMMITS_CONTEXT_KEY {
|
if gui.currentContext().GetKey() == context.SUB_COMMITS_CONTEXT_KEY {
|
||||||
|
@ -90,7 +90,7 @@ func (gui *Gui) handleToggleSelectionForPatch() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := gui.refreshCommitFilesView(); err != nil {
|
if err := gui.refreshCommitFilesContext(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,5 +194,5 @@ func (gui *Gui) handleResetPatch() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return gui.refreshCommitFilesView()
|
return gui.refreshCommitFilesContext()
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ func (gui *Gui) refreshCommits() {
|
|||||||
commit := gui.getSelectedLocalCommit()
|
commit := gui.getSelectedLocalCommit()
|
||||||
if commit != nil {
|
if commit != nil {
|
||||||
gui.State.Contexts.CommitFiles.SetRefName(commit.RefName())
|
gui.State.Contexts.CommitFiles.SetRefName(commit.RefName())
|
||||||
_ = gui.refreshCommitFilesView()
|
_ = gui.refreshCommitFilesContext()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wg.Done()
|
wg.Done()
|
||||||
|
@ -33,6 +33,13 @@ type IBaseContext interface {
|
|||||||
SetWindowName(string)
|
SetWindowName(string)
|
||||||
GetKey() ContextKey
|
GetKey() ContextKey
|
||||||
IsFocusable() bool
|
IsFocusable() bool
|
||||||
|
// if a context is transient, then when it loses focus, its corresponding view
|
||||||
|
// returns control of the window to the default view for that window
|
||||||
|
IsTransient() bool
|
||||||
|
|
||||||
|
// returns the desired title for the view upon activation. If there is no desired title (returns empty string), then
|
||||||
|
// no title will be set
|
||||||
|
Title() string
|
||||||
|
|
||||||
GetOptionsMap() map[string]string
|
GetOptionsMap() map[string]string
|
||||||
|
|
||||||
|
@ -35,5 +35,7 @@ func (gui *Gui) currentWindow() string {
|
|||||||
func (gui *Gui) resetWindowContext(c types.Context) {
|
func (gui *Gui) resetWindowContext(c types.Context) {
|
||||||
// we assume here that the window contains as its default view a view with the same name as the window
|
// we assume here that the window contains as its default view a view with the same name as the window
|
||||||
windowName := c.GetWindowName()
|
windowName := c.GetWindowName()
|
||||||
gui.State.WindowViewNameMap[windowName] = windowName
|
if gui.State.WindowViewNameMap[windowName] == c.GetViewName() {
|
||||||
|
gui.State.WindowViewNameMap[windowName] = windowName
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -230,6 +230,8 @@ type TranslationSet struct {
|
|||||||
CheckingOutStatus string
|
CheckingOutStatus string
|
||||||
CommittingStatus string
|
CommittingStatus string
|
||||||
CommitFiles string
|
CommitFiles string
|
||||||
|
SubCommitsDynamicTitle string
|
||||||
|
CommitFilesDynamicTitle string
|
||||||
LcViewItemFiles string
|
LcViewItemFiles string
|
||||||
CommitFilesTitle string
|
CommitFilesTitle string
|
||||||
LcCheckoutCommitFile string
|
LcCheckoutCommitFile string
|
||||||
@ -819,6 +821,8 @@ func EnglishTranslationSet() TranslationSet {
|
|||||||
CheckingOutStatus: "checking out",
|
CheckingOutStatus: "checking out",
|
||||||
CommittingStatus: "committing",
|
CommittingStatus: "committing",
|
||||||
CommitFiles: "Commit files",
|
CommitFiles: "Commit files",
|
||||||
|
SubCommitsDynamicTitle: "Commits for %s",
|
||||||
|
CommitFilesDynamicTitle: "Diff files for %s",
|
||||||
LcViewItemFiles: "view selected item's files",
|
LcViewItemFiles: "view selected item's files",
|
||||||
CommitFilesTitle: "Commit Files",
|
CommitFilesTitle: "Commit Files",
|
||||||
LcCheckoutCommitFile: "checkout file",
|
LcCheckoutCommitFile: "checkout file",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user