mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-30 11:06:37 -04:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
02bf6a5c17 | ||
|
|
8abc953582 | ||
|
|
9c4f837d45 | ||
|
|
2f45db8f7c |
@@ -186,6 +186,47 @@ func (gui *Gui) branchCommitsListContext() IListContext {
|
||||
}
|
||||
}
|
||||
|
||||
func (gui *Gui) subCommitsListContext() IListContext {
|
||||
parseEmoji := gui.Config.GetUserConfig().Git.ParseEmoji
|
||||
return &ListContext{
|
||||
BasicContext: &BasicContext{
|
||||
ViewName: "branches",
|
||||
WindowName: "branches",
|
||||
Key: SUB_COMMITS_CONTEXT_KEY,
|
||||
Kind: SIDE_CONTEXT,
|
||||
},
|
||||
GetItemsLength: func() int { return len(gui.State.SubCommits) },
|
||||
OnGetPanelState: func() IListPanelState { return gui.State.Panels.SubCommits },
|
||||
OnFocus: gui.handleSubCommitSelect,
|
||||
Gui: gui,
|
||||
GetDisplayStrings: func(startIdx int, length int) [][]string {
|
||||
selectedCommitSha := ""
|
||||
if gui.currentContext().GetKey() == SUB_COMMITS_CONTEXT_KEY {
|
||||
selectedCommit := gui.getSelectedSubCommit()
|
||||
if selectedCommit != nil {
|
||||
selectedCommitSha = selectedCommit.Sha
|
||||
}
|
||||
}
|
||||
return presentation.GetCommitListDisplayStrings(
|
||||
gui.State.SubCommits,
|
||||
gui.State.ScreenMode != SCREEN_NORMAL,
|
||||
gui.cherryPickedCommitShaMap(),
|
||||
gui.State.Modes.Diffing.Ref,
|
||||
parseEmoji,
|
||||
selectedCommitSha,
|
||||
startIdx,
|
||||
length,
|
||||
gui.shouldShowGraph(),
|
||||
)
|
||||
},
|
||||
SelectedItem: func() (ListItem, bool) {
|
||||
item := gui.getSelectedSubCommit()
|
||||
return item, item != nil
|
||||
},
|
||||
RenderSelection: true,
|
||||
}
|
||||
}
|
||||
|
||||
func (gui *Gui) shouldShowGraph() bool {
|
||||
value := gui.Config.GetUserConfig().Git.Log.ShowGraph
|
||||
switch value {
|
||||
@@ -230,47 +271,6 @@ func (gui *Gui) reflogCommitsListContext() IListContext {
|
||||
}
|
||||
}
|
||||
|
||||
func (gui *Gui) subCommitsListContext() IListContext {
|
||||
parseEmoji := gui.Config.GetUserConfig().Git.ParseEmoji
|
||||
return &ListContext{
|
||||
BasicContext: &BasicContext{
|
||||
ViewName: "branches",
|
||||
WindowName: "branches",
|
||||
Key: SUB_COMMITS_CONTEXT_KEY,
|
||||
Kind: SIDE_CONTEXT,
|
||||
},
|
||||
GetItemsLength: func() int { return len(gui.State.SubCommits) },
|
||||
OnGetPanelState: func() IListPanelState { return gui.State.Panels.SubCommits },
|
||||
OnFocus: gui.handleSubCommitSelect,
|
||||
Gui: gui,
|
||||
GetDisplayStrings: func(startIdx int, length int) [][]string {
|
||||
selectedCommitSha := ""
|
||||
if gui.currentContext().GetKey() == SUB_COMMITS_CONTEXT_KEY {
|
||||
selectedCommit := gui.getSelectedSubCommit()
|
||||
if selectedCommit != nil {
|
||||
selectedCommitSha = selectedCommit.Sha
|
||||
}
|
||||
}
|
||||
return presentation.GetCommitListDisplayStrings(
|
||||
gui.State.SubCommits,
|
||||
gui.State.ScreenMode != SCREEN_NORMAL,
|
||||
gui.cherryPickedCommitShaMap(),
|
||||
gui.State.Modes.Diffing.Ref,
|
||||
parseEmoji,
|
||||
selectedCommitSha,
|
||||
0,
|
||||
len(gui.State.SubCommits),
|
||||
gui.shouldShowGraph(),
|
||||
)
|
||||
},
|
||||
SelectedItem: func() (ListItem, bool) {
|
||||
item := gui.getSelectedSubCommit()
|
||||
return item, item != nil
|
||||
},
|
||||
RenderSelection: true,
|
||||
}
|
||||
}
|
||||
|
||||
func (gui *Gui) stashListContext() IListContext {
|
||||
return &ListContext{
|
||||
BasicContext: &BasicContext{
|
||||
|
||||
+11
-9
@@ -12,18 +12,24 @@ import (
|
||||
"github.com/jesseduffield/gocui"
|
||||
)
|
||||
|
||||
func (gui *Gui) desiredPtySize() *pty.Winsize {
|
||||
width, height := gui.Views.Main.Size()
|
||||
|
||||
return &pty.Winsize{Cols: uint16(width), Rows: uint16(height)}
|
||||
}
|
||||
|
||||
func (gui *Gui) onResize() error {
|
||||
if gui.State.Ptmx == nil {
|
||||
return nil
|
||||
}
|
||||
width, height := gui.Views.Main.Size()
|
||||
|
||||
if err := pty.Setsize(gui.State.Ptmx, &pty.Winsize{Cols: uint16(width), Rows: uint16(height)}); err != nil {
|
||||
// TODO: handle resizing properly: we need to actually clear the main view
|
||||
// and re-read the output from our pty. Or we could just re-run the original
|
||||
// command from scratch
|
||||
if err := pty.Setsize(gui.State.Ptmx, gui.desiredPtySize()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO: handle resizing properly
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -52,7 +58,7 @@ func (gui *Gui) newPtyTask(view *gocui.View, cmd *exec.Cmd, prefix string) error
|
||||
manager := gui.getManager(view)
|
||||
|
||||
start := func() (*exec.Cmd, io.Reader) {
|
||||
ptmx, err := pty.Start(cmd)
|
||||
ptmx, err := pty.StartWithSize(cmd, gui.desiredPtySize())
|
||||
if err != nil {
|
||||
gui.Log.Error(err)
|
||||
}
|
||||
@@ -67,10 +73,6 @@ func (gui *Gui) newPtyTask(view *gocui.View, cmd *exec.Cmd, prefix string) error
|
||||
gui.State.Ptmx = nil
|
||||
}
|
||||
|
||||
if err := gui.onResize(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := manager.NewTask(manager.NewCmdTask(start, prefix, height+oy+10, onClose), cmdStr); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
+1
-1
@@ -263,7 +263,7 @@ func chineseTranslationSet() TranslationSet {
|
||||
LcViewDiscardOptions: "查看'放弃更改‘选项",
|
||||
LcCancel: "取消",
|
||||
LcDiscardAllChanges: "放弃所有更改",
|
||||
LcDiscardUnstagedChanges: "放弃未进行的变更",
|
||||
LcDiscardUnstagedChanges: "放弃未暂存的变更",
|
||||
LcDiscardAllChangesToAllFiles: "清空工作区",
|
||||
LcDiscardAnyUnstagedChanges: "丢弃未暂存的变更",
|
||||
LcDiscardUntrackedFiles: "丢弃未跟踪的文件",
|
||||
|
||||
Reference in New Issue
Block a user