mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-02 23:27:32 +02:00
fix up patch manager
This commit is contained in:
parent
5cdfd41dca
commit
bd66162972
@ -113,10 +113,6 @@ func (gui *Gui) handleEditCommitFile(g *gocui.Gui, v *gocui.View) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleToggleFileForPatch(g *gocui.Gui, v *gocui.View) error {
|
func (gui *Gui) handleToggleFileForPatch(g *gocui.Gui, v *gocui.View) error {
|
||||||
if ok, err := gui.validateNormalWorkingTreeState(); !ok {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
commitFile := gui.getSelectedCommitFile()
|
commitFile := gui.getSelectedCommitFile()
|
||||||
if commitFile == nil {
|
if commitFile == nil {
|
||||||
gui.renderString("commitFiles", gui.Tr.SLocalize("NoCommiteFiles"))
|
gui.renderString("commitFiles", gui.Tr.SLocalize("NoCommiteFiles"))
|
||||||
@ -172,10 +168,6 @@ func (gui *Gui) handleEnterCommitFile(g *gocui.Gui, v *gocui.View) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) enterCommitFile(selectedLineIdx int) error {
|
func (gui *Gui) enterCommitFile(selectedLineIdx int) error {
|
||||||
if ok, err := gui.validateNormalWorkingTreeState(); !ok {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
commitFile := gui.getSelectedCommitFile()
|
commitFile := gui.getSelectedCommitFile()
|
||||||
if commitFile == nil {
|
if commitFile == nil {
|
||||||
gui.renderString("commitFiles", gui.Tr.SLocalize("NoCommiteFiles"))
|
gui.renderString("commitFiles", gui.Tr.SLocalize("NoCommiteFiles"))
|
||||||
|
@ -343,6 +343,21 @@ func (gui *Gui) viewTabContextMap() map[string][]tabContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) currentContextKeyIgnoringPopups() string {
|
||||||
|
stack := gui.State.ContextStack
|
||||||
|
|
||||||
|
for i := range stack {
|
||||||
|
reversedIndex := len(stack) - 1 - i
|
||||||
|
context := stack[reversedIndex]
|
||||||
|
kind := stack[reversedIndex].GetKind()
|
||||||
|
if kind != TEMPORARY_POPUP && kind != PERSISTENT_POPUP {
|
||||||
|
return context.GetKey()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func (gui *Gui) switchContext(c Context) error {
|
func (gui *Gui) switchContext(c Context) error {
|
||||||
gui.g.Update(func(*gocui.Gui) error {
|
gui.g.Update(func(*gocui.Gui) error {
|
||||||
// push onto stack
|
// push onto stack
|
||||||
|
@ -26,7 +26,7 @@ func (gui *Gui) handleCreatePatchOptionsMenu(g *gocui.Gui, v *gocui.View) error
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if gui.GitCommand.PatchManager.CanRebase {
|
if gui.GitCommand.PatchManager.CanRebase && gui.workingTreeState() == "normal" {
|
||||||
menuItems = append(menuItems, []*menuItem{
|
menuItems = append(menuItems, []*menuItem{
|
||||||
{
|
{
|
||||||
displayString: fmt.Sprintf("remove patch from original commit (%s)", gui.GitCommand.PatchManager.To),
|
displayString: fmt.Sprintf("remove patch from original commit (%s)", gui.GitCommand.PatchManager.To),
|
||||||
@ -74,9 +74,6 @@ func (gui *Gui) getPatchCommitIndex() int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) validateNormalWorkingTreeState() (bool, error) {
|
func (gui *Gui) validateNormalWorkingTreeState() (bool, error) {
|
||||||
if gui.GitCommand.WorkingTreeState() != "normal" {
|
|
||||||
return false, gui.createErrorPanel(gui.Tr.SLocalize("CantPatchWhileRebasingError"))
|
|
||||||
}
|
|
||||||
if gui.GitCommand.WorkingTreeState() != "normal" {
|
if gui.GitCommand.WorkingTreeState() != "normal" {
|
||||||
return false, gui.createErrorPanel(gui.Tr.SLocalize("CantPatchWhileRebasingError"))
|
return false, gui.createErrorPanel(gui.Tr.SLocalize("CantPatchWhileRebasingError"))
|
||||||
}
|
}
|
||||||
@ -183,5 +180,10 @@ func (gui *Gui) handleApplyPatch(reverse bool) error {
|
|||||||
|
|
||||||
func (gui *Gui) handleResetPatch() error {
|
func (gui *Gui) handleResetPatch() error {
|
||||||
gui.GitCommand.PatchManager.Reset()
|
gui.GitCommand.PatchManager.Reset()
|
||||||
|
if gui.currentContextKeyIgnoringPopups() == MAIN_PATCH_BUILDING_CONTEXT_KEY {
|
||||||
|
if err := gui.switchContext(gui.Contexts.CommitFiles.Context); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
return gui.refreshCommitFilesView()
|
return gui.refreshCommitFilesView()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user