Repository: jesseduffield/lazygit
File: pkg/gui/custom_patch_options_panel.go (Go)

Code before:

func (gui *Gui) handleCreatePatchOptionsMenu() error {
	if !gui.git.Patch.PatchManager.Active() {
		return gui.c.ErrorMsg(gui.c.Tr.NoPatchError)
	}

	menuItems := []*types.MenuItem{
		{
			Label:   "reset patch",
			OnPress: gui.helpers.PatchBuilding.Reset,
			Key:     'c',
		},
		{
			Label:   "apply patch",
			OnPress: func() error { return gui.handleApplyPatch(false) },
			Key:     'a',
		},
		{
			Label:   "apply patch in reverse",
			OnPress: func() error { return gui.handleApplyPatch(true) },
			Key:     'r',
		},
		{
			Label:   "Copy patch to clipboard",
			OnPress: func() error { return gui.copyPatchToClipbaord() },
			Key:     gocui.KeyCtrlO,
		},
	}

	if gui.git.Patch.PatchManager.CanRebase && gui.git.Status.WorkingTreeState() == enums.REBASE_MODE_NONE {
		menuItems = append(menuItems, []*types.MenuItem{
			{
				Label:   fmt.Sprintf("remove patch from original commit (%s)", gui.git.Patch.PatchManager.To),
				OnPress: gui.handleDeletePatchFromCommit,
				Key:     'd',
			},
			{
				Label:   "move patch out into index",
				OnPress: gui.handleMovePatchIntoWorkingTree,
				Key:     'i',
			},
			{
				Label:   "move patch into new commit",
				OnPress: gui.handlePullPatchIntoNewCommit,
				Key:     'n',
			},
		}...)

		if gui.currentContext().GetKey() == gui.State.Contexts.LocalCommits.GetKey() {
			selectedCommit := gui.getSelectedLocalCommit()
			if selectedCommit != nil && gui.git.Patch.PatchManager.To != selectedCommit.Sha {

Review comment (suggestion):
I propose `y`, since we're already in a menu, holding `ctrl` really isn't necessary, we have keyboard real-estate to use :)

And cuz `vim`.

Code after:
func (gui *Gui) handleCreatePatchOptionsMenu() error {
	if !gui.git.Patch.PatchManager.Active() {
		return gui.c.ErrorMsg(gui.c.Tr.NoPatchError)
	}

	menuItems := []*types.MenuItem{
		{
			Label:   "reset patch",
			OnPress: gui.helpers.PatchBuilding.Reset,
			Key:     'c',
		},
		{
			Label:   "apply patch",
			OnPress: func() error { return gui.handleApplyPatch(false) },
			Key:     'a',
		},
		{
			Label:   "apply patch in reverse",
			OnPress: func() error { return gui.handleApplyPatch(true) },
			Key:     'r',
		},
	}

	if gui.git.Patch.PatchManager.CanRebase && gui.git.Status.WorkingTreeState() == enums.REBASE_MODE_NONE {
		menuItems = append(menuItems, []*types.MenuItem{
			{
				Label:   fmt.Sprintf("remove patch from original commit (%s)", gui.git.Patch.PatchManager.To),
				OnPress: gui.handleDeletePatchFromCommit,
				Key:     'd',
			},
			{
				Label:   "move patch out into index",
				OnPress: gui.handleMovePatchIntoWorkingTree,
				Key:     'i',
			},
			{
				Label:   "move patch into new commit",
				OnPress: gui.handlePullPatchIntoNewCommit,
				Key:     'n',
			},
		}...)

		if gui.currentContext().GetKey() == gui.State.Contexts.LocalCommits.GetKey() {
			selectedCommit := gui.getSelectedLocalCommit()
			if selectedCommit != nil && gui.git.Patch.PatchManager.To != selectedCommit.Sha {
				// adding this option to index 1
				menuItems = append(
					menuItems[:1],
					append(
						[]*types.MenuItem{
							{