mirror of
https://github.com/jesseduffield/lazygit.git
synced 2024-12-02 09:21:40 +02:00
rename to SelectedLineIdx
This commit is contained in:
parent
eb5e54e9fd
commit
146722beb8
@ -15,7 +15,7 @@ func (gui *Gui) getSelectedBranch() *commands.Branch {
|
||||
return nil
|
||||
}
|
||||
|
||||
selectedLine := gui.State.Panels.Branches.SelectedLine
|
||||
selectedLine := gui.State.Panels.Branches.SelectedLineIdx
|
||||
if selectedLine == -1 {
|
||||
return nil
|
||||
}
|
||||
@ -76,10 +76,10 @@ func (gui *Gui) refreshBranches() {
|
||||
// specific functions
|
||||
|
||||
func (gui *Gui) handleBranchPress(g *gocui.Gui, v *gocui.View) error {
|
||||
if gui.State.Panels.Branches.SelectedLine == -1 {
|
||||
if gui.State.Panels.Branches.SelectedLineIdx == -1 {
|
||||
return nil
|
||||
}
|
||||
if gui.State.Panels.Branches.SelectedLine == 0 {
|
||||
if gui.State.Panels.Branches.SelectedLineIdx == 0 {
|
||||
return gui.createErrorPanel(gui.Tr.SLocalize("AlreadyCheckedOutBranch"))
|
||||
}
|
||||
branch := gui.getSelectedBranch()
|
||||
@ -143,8 +143,8 @@ func (gui *Gui) handleCheckoutRef(ref string, options handleCheckoutRefOptions)
|
||||
cmdOptions := commands.CheckoutOptions{Force: false, EnvVars: options.EnvVars}
|
||||
|
||||
onSuccess := func() {
|
||||
gui.State.Panels.Branches.SelectedLine = 0
|
||||
gui.State.Panels.Commits.SelectedLine = 0
|
||||
gui.State.Panels.Branches.SelectedLineIdx = 0
|
||||
gui.State.Panels.Commits.SelectedLineIdx = 0
|
||||
// loading a heap of commits is slow so we limit them whenever doing a reset
|
||||
gui.State.Panels.Commits.LimitCommits = true
|
||||
}
|
||||
@ -246,7 +246,7 @@ func (gui *Gui) createNewBranchWithName(newBranchName string) error {
|
||||
if err := gui.GitCommand.NewBranch(newBranchName, branch.Name); err != nil {
|
||||
return gui.surfaceError(err)
|
||||
}
|
||||
gui.State.Panels.Branches.SelectedLine = 0
|
||||
gui.State.Panels.Branches.SelectedLineIdx = 0
|
||||
return gui.refreshSidePanels(refreshOptions{mode: ASYNC})
|
||||
}
|
||||
|
||||
@ -408,7 +408,7 @@ func (gui *Gui) handleFastForward(g *gocui.Gui, v *gocui.View) error {
|
||||
go func() {
|
||||
_ = gui.createLoaderPanel(v, message)
|
||||
|
||||
if gui.State.Panels.Branches.SelectedLine == 0 {
|
||||
if gui.State.Panels.Branches.SelectedLineIdx == 0 {
|
||||
_ = gui.pullWithMode("ff-only", PullFilesOptions{})
|
||||
} else {
|
||||
err := gui.GitCommand.FastForward(branch.Name, remoteName, remoteBranchName, gui.promptUserForCredential)
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
func (gui *Gui) getSelectedCommitFile() *commands.CommitFile {
|
||||
selectedLine := gui.State.Panels.CommitFiles.SelectedLine
|
||||
selectedLine := gui.State.Panels.CommitFiles.SelectedLineIdx
|
||||
if selectedLine == -1 {
|
||||
return nil
|
||||
}
|
||||
@ -44,7 +44,7 @@ func (gui *Gui) handleSwitchToCommitsPanel(g *gocui.Gui, v *gocui.View) error {
|
||||
}
|
||||
|
||||
func (gui *Gui) handleCheckoutCommitFile(g *gocui.Gui, v *gocui.View) error {
|
||||
file := gui.State.CommitFiles[gui.State.Panels.CommitFiles.SelectedLine]
|
||||
file := gui.State.CommitFiles[gui.State.Panels.CommitFiles.SelectedLineIdx]
|
||||
|
||||
if err := gui.GitCommand.CheckoutFile(file.Sha, file.Name); err != nil {
|
||||
return gui.surfaceError(err)
|
||||
@ -58,7 +58,7 @@ func (gui *Gui) handleDiscardOldFileChange(g *gocui.Gui, v *gocui.View) error {
|
||||
return err
|
||||
}
|
||||
|
||||
fileName := gui.State.CommitFiles[gui.State.Panels.CommitFiles.SelectedLine].Name
|
||||
fileName := gui.State.CommitFiles[gui.State.Panels.CommitFiles.SelectedLineIdx].Name
|
||||
|
||||
return gui.ask(askOpts{
|
||||
returnToView: v,
|
||||
@ -67,7 +67,7 @@ func (gui *Gui) handleDiscardOldFileChange(g *gocui.Gui, v *gocui.View) error {
|
||||
prompt: gui.Tr.SLocalize("DiscardFileChangesPrompt"),
|
||||
handleConfirm: func() error {
|
||||
return gui.WithWaitingStatus(gui.Tr.SLocalize("RebasingStatus"), func() error {
|
||||
if err := gui.GitCommand.DiscardOldFileChanges(gui.State.Commits, gui.State.Panels.Commits.SelectedLine, fileName); err != nil {
|
||||
if err := gui.GitCommand.DiscardOldFileChanges(gui.State.Commits, gui.State.Panels.Commits.SelectedLineIdx, fileName); err != nil {
|
||||
if err := gui.handleGenericMergeCommandResult(err); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
// list panel functions
|
||||
|
||||
func (gui *Gui) getSelectedCommit() *commands.Commit {
|
||||
selectedLine := gui.State.Panels.Commits.SelectedLine
|
||||
selectedLine := gui.State.Panels.Commits.SelectedLineIdx
|
||||
if selectedLine == -1 {
|
||||
return nil
|
||||
}
|
||||
@ -21,7 +21,7 @@ func (gui *Gui) getSelectedCommit() *commands.Commit {
|
||||
|
||||
func (gui *Gui) handleCommitSelect() error {
|
||||
state := gui.State.Panels.Commits
|
||||
if state.SelectedLine > 290 && state.LimitCommits {
|
||||
if state.SelectedLineIdx > 290 && state.LimitCommits {
|
||||
state.LimitCommits = false
|
||||
go func() {
|
||||
if err := gui.refreshCommitsWithLimit(); err != nil {
|
||||
@ -138,7 +138,7 @@ func (gui *Gui) handleCommitSquashDown(g *gocui.Gui, v *gocui.View) error {
|
||||
prompt: gui.Tr.SLocalize("SureSquashThisCommit"),
|
||||
handleConfirm: func() error {
|
||||
return gui.WithWaitingStatus(gui.Tr.SLocalize("SquashingStatus"), func() error {
|
||||
err := gui.GitCommand.InteractiveRebase(gui.State.Commits, gui.State.Panels.Commits.SelectedLine, "squash")
|
||||
err := gui.GitCommand.InteractiveRebase(gui.State.Commits, gui.State.Panels.Commits.SelectedLineIdx, "squash")
|
||||
return gui.handleGenericMergeCommandResult(err)
|
||||
})
|
||||
},
|
||||
@ -169,7 +169,7 @@ func (gui *Gui) handleCommitFixup(g *gocui.Gui, v *gocui.View) error {
|
||||
prompt: gui.Tr.SLocalize("SureFixupThisCommit"),
|
||||
handleConfirm: func() error {
|
||||
return gui.WithWaitingStatus(gui.Tr.SLocalize("FixingStatus"), func() error {
|
||||
err := gui.GitCommand.InteractiveRebase(gui.State.Commits, gui.State.Panels.Commits.SelectedLine, "fixup")
|
||||
err := gui.GitCommand.InteractiveRebase(gui.State.Commits, gui.State.Panels.Commits.SelectedLineIdx, "fixup")
|
||||
return gui.handleGenericMergeCommandResult(err)
|
||||
})
|
||||
},
|
||||
@ -189,7 +189,7 @@ func (gui *Gui) handleRenameCommit(g *gocui.Gui, v *gocui.View) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
if gui.State.Panels.Commits.SelectedLine != 0 {
|
||||
if gui.State.Panels.Commits.SelectedLineIdx != 0 {
|
||||
return gui.createErrorPanel(gui.Tr.SLocalize("OnlyRenameTopCommit"))
|
||||
}
|
||||
|
||||
@ -225,7 +225,7 @@ func (gui *Gui) handleRenameCommitEditor(g *gocui.Gui, v *gocui.View) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
subProcess, err := gui.GitCommand.RewordCommit(gui.State.Commits, gui.State.Panels.Commits.SelectedLine)
|
||||
subProcess, err := gui.GitCommand.RewordCommit(gui.State.Commits, gui.State.Panels.Commits.SelectedLineIdx)
|
||||
if err != nil {
|
||||
return gui.surfaceError(err)
|
||||
}
|
||||
@ -241,7 +241,7 @@ func (gui *Gui) handleRenameCommitEditor(g *gocui.Gui, v *gocui.View) error {
|
||||
// commit meaning you are trying to edit the todo file rather than actually
|
||||
// begin a rebase. It then updates the todo file with that action
|
||||
func (gui *Gui) handleMidRebaseCommand(action string) (bool, error) {
|
||||
selectedCommit := gui.State.Commits[gui.State.Panels.Commits.SelectedLine]
|
||||
selectedCommit := gui.State.Commits[gui.State.Panels.Commits.SelectedLineIdx]
|
||||
if selectedCommit.Status != "rebasing" {
|
||||
return false, nil
|
||||
}
|
||||
@ -254,7 +254,7 @@ func (gui *Gui) handleMidRebaseCommand(action string) (bool, error) {
|
||||
return true, gui.createErrorPanel(gui.Tr.SLocalize("rewordNotSupported"))
|
||||
}
|
||||
|
||||
if err := gui.GitCommand.EditRebaseTodo(gui.State.Panels.Commits.SelectedLine, action); err != nil {
|
||||
if err := gui.GitCommand.EditRebaseTodo(gui.State.Panels.Commits.SelectedLineIdx, action); err != nil {
|
||||
return false, gui.surfaceError(err)
|
||||
}
|
||||
// TODO: consider doing this in a way that is less expensive. We don't actually
|
||||
@ -282,7 +282,7 @@ func (gui *Gui) handleCommitDelete(g *gocui.Gui, v *gocui.View) error {
|
||||
prompt: gui.Tr.SLocalize("DeleteCommitPrompt"),
|
||||
handleConfirm: func() error {
|
||||
return gui.WithWaitingStatus(gui.Tr.SLocalize("DeletingStatus"), func() error {
|
||||
err := gui.GitCommand.InteractiveRebase(gui.State.Commits, gui.State.Panels.Commits.SelectedLine, "drop")
|
||||
err := gui.GitCommand.InteractiveRebase(gui.State.Commits, gui.State.Panels.Commits.SelectedLineIdx, "drop")
|
||||
return gui.handleGenericMergeCommandResult(err)
|
||||
})
|
||||
},
|
||||
@ -294,7 +294,7 @@ func (gui *Gui) handleCommitMoveDown(g *gocui.Gui, v *gocui.View) error {
|
||||
return err
|
||||
}
|
||||
|
||||
index := gui.State.Panels.Commits.SelectedLine
|
||||
index := gui.State.Panels.Commits.SelectedLineIdx
|
||||
selectedCommit := gui.State.Commits[index]
|
||||
if selectedCommit.Status == "rebasing" {
|
||||
if gui.State.Commits[index+1].Status != "rebasing" {
|
||||
@ -303,14 +303,14 @@ func (gui *Gui) handleCommitMoveDown(g *gocui.Gui, v *gocui.View) error {
|
||||
if err := gui.GitCommand.MoveTodoDown(index); err != nil {
|
||||
return gui.surfaceError(err)
|
||||
}
|
||||
gui.State.Panels.Commits.SelectedLine++
|
||||
gui.State.Panels.Commits.SelectedLineIdx++
|
||||
return gui.refreshSidePanels(refreshOptions{mode: BLOCK_UI, scope: []int{COMMITS, BRANCHES}})
|
||||
}
|
||||
|
||||
return gui.WithWaitingStatus(gui.Tr.SLocalize("MovingStatus"), func() error {
|
||||
err := gui.GitCommand.MoveCommitDown(gui.State.Commits, index)
|
||||
if err == nil {
|
||||
gui.State.Panels.Commits.SelectedLine++
|
||||
gui.State.Panels.Commits.SelectedLineIdx++
|
||||
}
|
||||
return gui.handleGenericMergeCommandResult(err)
|
||||
})
|
||||
@ -321,7 +321,7 @@ func (gui *Gui) handleCommitMoveUp(g *gocui.Gui, v *gocui.View) error {
|
||||
return err
|
||||
}
|
||||
|
||||
index := gui.State.Panels.Commits.SelectedLine
|
||||
index := gui.State.Panels.Commits.SelectedLineIdx
|
||||
if index == 0 {
|
||||
return nil
|
||||
}
|
||||
@ -330,14 +330,14 @@ func (gui *Gui) handleCommitMoveUp(g *gocui.Gui, v *gocui.View) error {
|
||||
if err := gui.GitCommand.MoveTodoDown(index - 1); err != nil {
|
||||
return gui.surfaceError(err)
|
||||
}
|
||||
gui.State.Panels.Commits.SelectedLine--
|
||||
gui.State.Panels.Commits.SelectedLineIdx--
|
||||
return gui.refreshSidePanels(refreshOptions{mode: BLOCK_UI, scope: []int{COMMITS, BRANCHES}})
|
||||
}
|
||||
|
||||
return gui.WithWaitingStatus(gui.Tr.SLocalize("MovingStatus"), func() error {
|
||||
err := gui.GitCommand.MoveCommitDown(gui.State.Commits, index-1)
|
||||
if err == nil {
|
||||
gui.State.Panels.Commits.SelectedLine--
|
||||
gui.State.Panels.Commits.SelectedLineIdx--
|
||||
}
|
||||
return gui.handleGenericMergeCommandResult(err)
|
||||
})
|
||||
@ -357,7 +357,7 @@ func (gui *Gui) handleCommitEdit(g *gocui.Gui, v *gocui.View) error {
|
||||
}
|
||||
|
||||
return gui.WithWaitingStatus(gui.Tr.SLocalize("RebasingStatus"), func() error {
|
||||
err = gui.GitCommand.InteractiveRebase(gui.State.Commits, gui.State.Panels.Commits.SelectedLine, "edit")
|
||||
err = gui.GitCommand.InteractiveRebase(gui.State.Commits, gui.State.Panels.Commits.SelectedLineIdx, "edit")
|
||||
return gui.handleGenericMergeCommandResult(err)
|
||||
})
|
||||
}
|
||||
@ -374,7 +374,7 @@ func (gui *Gui) handleCommitAmendTo(g *gocui.Gui, v *gocui.View) error {
|
||||
prompt: gui.Tr.SLocalize("AmendCommitPrompt"),
|
||||
handleConfirm: func() error {
|
||||
return gui.WithWaitingStatus(gui.Tr.SLocalize("AmendingStatus"), func() error {
|
||||
err := gui.GitCommand.AmendTo(gui.State.Commits[gui.State.Panels.Commits.SelectedLine].Sha)
|
||||
err := gui.GitCommand.AmendTo(gui.State.Commits[gui.State.Panels.Commits.SelectedLineIdx].Sha)
|
||||
return gui.handleGenericMergeCommandResult(err)
|
||||
})
|
||||
},
|
||||
@ -404,10 +404,10 @@ func (gui *Gui) handleCommitRevert(g *gocui.Gui, v *gocui.View) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := gui.GitCommand.Revert(gui.State.Commits[gui.State.Panels.Commits.SelectedLine].Sha); err != nil {
|
||||
if err := gui.GitCommand.Revert(gui.State.Commits[gui.State.Panels.Commits.SelectedLineIdx].Sha); err != nil {
|
||||
return gui.surfaceError(err)
|
||||
}
|
||||
gui.State.Panels.Commits.SelectedLine++
|
||||
gui.State.Panels.Commits.SelectedLineIdx++
|
||||
return gui.refreshSidePanels(refreshOptions{mode: BLOCK_UI, scope: []int{COMMITS, BRANCHES}})
|
||||
}
|
||||
|
||||
@ -417,7 +417,7 @@ func (gui *Gui) handleCopyCommit(g *gocui.Gui, v *gocui.View) error {
|
||||
}
|
||||
|
||||
// get currently selected commit, add the sha to state.
|
||||
commit := gui.State.Commits[gui.State.Panels.Commits.SelectedLine]
|
||||
commit := gui.State.Commits[gui.State.Panels.Commits.SelectedLineIdx]
|
||||
|
||||
// we will un-copy it if it's already copied
|
||||
for index, cherryPickedCommit := range gui.State.CherryPickedCommits {
|
||||
@ -427,7 +427,7 @@ func (gui *Gui) handleCopyCommit(g *gocui.Gui, v *gocui.View) error {
|
||||
}
|
||||
}
|
||||
|
||||
gui.addCommitToCherryPickedCommits(gui.State.Panels.Commits.SelectedLine)
|
||||
gui.addCommitToCherryPickedCommits(gui.State.Panels.Commits.SelectedLineIdx)
|
||||
return gui.Contexts.BranchCommits.Context.HandleRender()
|
||||
}
|
||||
|
||||
@ -464,7 +464,7 @@ func (gui *Gui) handleCopyCommitRange(g *gocui.Gui, v *gocui.View) error {
|
||||
// find the last commit that is copied that's above our position
|
||||
// if there are none, startIndex = 0
|
||||
startIndex := 0
|
||||
for index, commit := range gui.State.Commits[0:gui.State.Panels.Commits.SelectedLine] {
|
||||
for index, commit := range gui.State.Commits[0:gui.State.Panels.Commits.SelectedLineIdx] {
|
||||
if commitShaMap[commit.Sha] {
|
||||
startIndex = index
|
||||
}
|
||||
@ -472,7 +472,7 @@ func (gui *Gui) handleCopyCommitRange(g *gocui.Gui, v *gocui.View) error {
|
||||
|
||||
gui.Log.Info("commit copy start index: " + strconv.Itoa(startIndex))
|
||||
|
||||
for index := startIndex; index <= gui.State.Panels.Commits.SelectedLine; index++ {
|
||||
for index := startIndex; index <= gui.State.Panels.Commits.SelectedLineIdx; index++ {
|
||||
gui.addCommitToCherryPickedCommits(index)
|
||||
}
|
||||
|
||||
@ -687,8 +687,8 @@ func (gui *Gui) handleNewBranchOffCommit() error {
|
||||
if err := gui.GitCommand.NewBranch(response, commit.Sha); err != nil {
|
||||
return err
|
||||
}
|
||||
gui.State.Panels.Commits.SelectedLine = 0
|
||||
gui.State.Panels.Branches.SelectedLine = 0
|
||||
gui.State.Panels.Commits.SelectedLineIdx = 0
|
||||
gui.State.Panels.Branches.SelectedLineIdx = 0
|
||||
|
||||
return gui.refreshSidePanels(refreshOptions{mode: ASYNC})
|
||||
})
|
||||
|
@ -19,7 +19,7 @@ import (
|
||||
// list panel functions
|
||||
|
||||
func (gui *Gui) getSelectedFile() *commands.File {
|
||||
selectedLine := gui.State.Panels.Files.SelectedLine
|
||||
selectedLine := gui.State.Panels.Files.SelectedLineIdx
|
||||
if selectedLine == -1 {
|
||||
return nil
|
||||
}
|
||||
@ -28,7 +28,7 @@ func (gui *Gui) getSelectedFile() *commands.File {
|
||||
}
|
||||
|
||||
func (gui *Gui) selectFile(alreadySelected bool) error {
|
||||
gui.getFilesView().FocusPoint(0, gui.State.Panels.Files.SelectedLine)
|
||||
gui.getFilesView().FocusPoint(0, gui.State.Panels.Files.SelectedLineIdx)
|
||||
|
||||
file := gui.getSelectedFile()
|
||||
if file == nil {
|
||||
@ -415,7 +415,7 @@ func (gui *Gui) refreshStateFiles() error {
|
||||
// let's try to find our file again and move the cursor to that
|
||||
for idx, f := range gui.State.Files {
|
||||
if selectedFile != nil && f.Matches(selectedFile) {
|
||||
gui.State.Panels.Files.SelectedLine = idx
|
||||
gui.State.Panels.Files.SelectedLineIdx = idx
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -102,15 +102,15 @@ type Gui struct {
|
||||
}
|
||||
|
||||
type listPanelState struct {
|
||||
SelectedLine int
|
||||
SelectedLineIdx int
|
||||
}
|
||||
|
||||
func (h *listPanelState) SetSelectedLineIdx(value int) {
|
||||
h.SelectedLine = value
|
||||
h.SelectedLineIdx = value
|
||||
}
|
||||
|
||||
func (h *listPanelState) GetSelectedLineIdx() int {
|
||||
return h.SelectedLine
|
||||
return h.SelectedLineIdx
|
||||
}
|
||||
|
||||
type IListPanelState interface {
|
||||
@ -284,16 +284,16 @@ func (gui *Gui) resetState() {
|
||||
CherryPickedCommits: make([]*commands.Commit, 0),
|
||||
StashEntries: make([]*commands.StashEntry, 0),
|
||||
Panels: &panelStates{
|
||||
Files: &filePanelState{listPanelState{SelectedLine: -1}},
|
||||
Branches: &branchPanelState{listPanelState{SelectedLine: 0}},
|
||||
Remotes: &remotePanelState{listPanelState{SelectedLine: 0}},
|
||||
RemoteBranches: &remoteBranchesState{listPanelState{SelectedLine: -1}},
|
||||
Tags: &tagsPanelState{listPanelState{SelectedLine: -1}},
|
||||
Commits: &commitPanelState{listPanelState: listPanelState{SelectedLine: -1}, LimitCommits: true},
|
||||
ReflogCommits: &reflogCommitPanelState{listPanelState{SelectedLine: 0}}, // TODO: might need to make -1
|
||||
CommitFiles: &commitFilesPanelState{listPanelState{SelectedLine: -1}},
|
||||
Stash: &stashPanelState{listPanelState{SelectedLine: -1}},
|
||||
Menu: &menuPanelState{listPanelState: listPanelState{SelectedLine: 0}, OnPress: nil},
|
||||
Files: &filePanelState{listPanelState{SelectedLineIdx: -1}},
|
||||
Branches: &branchPanelState{listPanelState{SelectedLineIdx: 0}},
|
||||
Remotes: &remotePanelState{listPanelState{SelectedLineIdx: 0}},
|
||||
RemoteBranches: &remoteBranchesState{listPanelState{SelectedLineIdx: -1}},
|
||||
Tags: &tagsPanelState{listPanelState{SelectedLineIdx: -1}},
|
||||
Commits: &commitPanelState{listPanelState: listPanelState{SelectedLineIdx: -1}, LimitCommits: true},
|
||||
ReflogCommits: &reflogCommitPanelState{listPanelState{SelectedLineIdx: 0}}, // TODO: might need to make -1
|
||||
CommitFiles: &commitFilesPanelState{listPanelState{SelectedLineIdx: -1}},
|
||||
Stash: &stashPanelState{listPanelState{SelectedLineIdx: -1}},
|
||||
Menu: &menuPanelState{listPanelState: listPanelState{SelectedLineIdx: 0}, OnPress: nil},
|
||||
Merging: &mergingPanelState{
|
||||
ConflictIndex: 0,
|
||||
ConflictTop: true,
|
||||
|
@ -225,7 +225,7 @@ func (gui *Gui) handleMouseScrollDown(g *gocui.Gui, v *gocui.View) error {
|
||||
}
|
||||
|
||||
func (gui *Gui) getSelectedCommitFileName() string {
|
||||
return gui.State.CommitFiles[gui.State.Panels.CommitFiles.SelectedLine].Name
|
||||
return gui.State.CommitFiles[gui.State.Panels.CommitFiles.SelectedLineIdx].Name
|
||||
}
|
||||
|
||||
func (gui *Gui) refreshMainView() error {
|
||||
|
@ -87,7 +87,7 @@ func (gui *Gui) createMenu(title string, items []*menuItem, createMenuOptions cr
|
||||
return nil
|
||||
}))
|
||||
fmt.Fprint(menuView, list)
|
||||
gui.State.Panels.Menu.SelectedLine = 0
|
||||
gui.State.Panels.Menu.SelectedLineIdx = 0
|
||||
|
||||
gui.g.Update(func(g *gocui.Gui) error {
|
||||
return gui.switchContext(gui.Contexts.Menu.Context)
|
||||
@ -96,7 +96,7 @@ func (gui *Gui) createMenu(title string, items []*menuItem, createMenuOptions cr
|
||||
}
|
||||
|
||||
func (gui *Gui) onMenuPress() error {
|
||||
selectedLine := gui.State.Panels.Menu.SelectedLine
|
||||
selectedLine := gui.State.Panels.Menu.SelectedLineIdx
|
||||
if err := gui.State.MenuItems[selectedLine].onPress(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ func (gui *Gui) handleMovePatchToSelectedCommit() error {
|
||||
|
||||
return gui.WithWaitingStatus(gui.Tr.SLocalize("RebasingStatus"), func() error {
|
||||
commitIndex := gui.getPatchCommitIndex()
|
||||
err := gui.GitCommand.MovePatchToSelectedCommit(gui.State.Commits, commitIndex, gui.State.Panels.Commits.SelectedLine, gui.GitCommand.PatchManager)
|
||||
err := gui.GitCommand.MovePatchToSelectedCommit(gui.State.Commits, commitIndex, gui.State.Panels.Commits.SelectedLineIdx, gui.GitCommand.PatchManager)
|
||||
return gui.handleGenericMergeCommandResult(err)
|
||||
})
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
// list panel functions
|
||||
|
||||
func (gui *Gui) getSelectedReflogCommit() *commands.Commit {
|
||||
selectedLine := gui.State.Panels.ReflogCommits.SelectedLine
|
||||
selectedLine := gui.State.Panels.ReflogCommits.SelectedLineIdx
|
||||
reflogComits := gui.State.FilteredReflogCommits
|
||||
if selectedLine == -1 || len(reflogComits) == 0 {
|
||||
return nil
|
||||
@ -102,7 +102,7 @@ func (gui *Gui) handleCheckoutReflogCommit(g *gocui.Gui, v *gocui.View) error {
|
||||
return err
|
||||
}
|
||||
|
||||
gui.State.Panels.ReflogCommits.SelectedLine = 0
|
||||
gui.State.Panels.ReflogCommits.SelectedLineIdx = 0
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
// list panel functions
|
||||
|
||||
func (gui *Gui) getSelectedRemoteBranch() *commands.RemoteBranch {
|
||||
selectedLine := gui.State.Panels.RemoteBranches.SelectedLine
|
||||
selectedLine := gui.State.Panels.RemoteBranches.SelectedLineIdx
|
||||
if selectedLine == -1 || len(gui.State.RemoteBranches) == 0 {
|
||||
return nil
|
||||
}
|
||||
@ -138,7 +138,7 @@ func (gui *Gui) handleNewBranchOffRemote(g *gocui.Gui, v *gocui.View) error {
|
||||
if err := gui.GitCommand.NewBranch(response, branch.FullName()); err != nil {
|
||||
return gui.surfaceError(err)
|
||||
}
|
||||
gui.State.Panels.Branches.SelectedLine = 0
|
||||
gui.State.Panels.Branches.SelectedLineIdx = 0
|
||||
|
||||
if err := gui.switchContext(gui.Contexts.Branches.Context); err != nil {
|
||||
return err
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
// list panel functions
|
||||
|
||||
func (gui *Gui) getSelectedRemote() *commands.Remote {
|
||||
selectedLine := gui.State.Panels.Remotes.SelectedLine
|
||||
selectedLine := gui.State.Panels.Remotes.SelectedLineIdx
|
||||
if selectedLine == -1 || len(gui.State.Remotes) == 0 {
|
||||
return nil
|
||||
}
|
||||
@ -74,7 +74,7 @@ func (gui *Gui) handleRemoteEnter() error {
|
||||
if len(remote.Branches) == 0 {
|
||||
newSelectedLine = -1
|
||||
}
|
||||
gui.State.Panels.RemoteBranches.SelectedLine = newSelectedLine
|
||||
gui.State.Panels.RemoteBranches.SelectedLineIdx = newSelectedLine
|
||||
|
||||
return gui.switchContext(gui.Contexts.Remotes.Branches.Context)
|
||||
}
|
||||
|
@ -12,8 +12,8 @@ func (gui *Gui) resetToRef(ref string, strength string, options commands.RunComm
|
||||
return gui.surfaceError(err)
|
||||
}
|
||||
|
||||
gui.State.Panels.Commits.SelectedLine = 0
|
||||
gui.State.Panels.ReflogCommits.SelectedLine = 0
|
||||
gui.State.Panels.Commits.SelectedLineIdx = 0
|
||||
gui.State.Panels.ReflogCommits.SelectedLineIdx = 0
|
||||
// loading a heap of commits is slow so we limit them whenever doing a reset
|
||||
gui.State.Panels.Commits.LimitCommits = true
|
||||
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
// list panel functions
|
||||
|
||||
func (gui *Gui) getSelectedStashEntry() *commands.StashEntry {
|
||||
selectedLine := gui.State.Panels.Stash.SelectedLine
|
||||
selectedLine := gui.State.Panels.Stash.SelectedLineIdx
|
||||
if selectedLine == -1 {
|
||||
return nil
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
// list panel functions
|
||||
|
||||
func (gui *Gui) getSelectedTag() *commands.Tag {
|
||||
selectedLine := gui.State.Panels.Tags.SelectedLine
|
||||
selectedLine := gui.State.Panels.Tags.SelectedLineIdx
|
||||
if selectedLine == -1 || len(gui.State.Tags) == 0 {
|
||||
return nil
|
||||
}
|
||||
@ -116,7 +116,7 @@ func (gui *Gui) handleCreateTag(g *gocui.Gui, v *gocui.View) error {
|
||||
// find the index of the tag and set that as the currently selected line
|
||||
for i, tag := range gui.State.Tags {
|
||||
if tag.Name == tagName {
|
||||
gui.State.Panels.Tags.SelectedLine = i
|
||||
gui.State.Panels.Tags.SelectedLineIdx = i
|
||||
if err := gui.Contexts.Tags.Context.HandleRender(); err != nil {
|
||||
gui.Log.Error(err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user