Repository: jesseduffield/lazygit
File: pkg/gui/controllers/helpers/refs_helper.go (Go)

Code before:
		return commit.Hash == branch.CommitHash && branch.Name != self.c.Model().CheckedOutBranch
	})

	ref := commit.Hash
	var menuItems []*types.MenuItem

	menuItems = append(menuItems, &types.MenuItem{
		LabelColumns: []string{fmt.Sprintf("%s %s", self.c.Tr.CheckoutCommit, self.c.Tr.AsDetachedHead), style.FgRed.Sprint(ref[:8])},
		OnPress: func() error {
			self.c.Confirm(types.ConfirmOpts{
				Title:  self.c.Tr.CheckoutCommit,
				Prompt: self.c.Tr.SureCheckoutThisCommit,
				HandleConfirm: func() error {
					self.c.LogAction(self.c.Tr.Actions.CheckoutCommit)
					return self.CheckoutRef(ref, types.CheckoutRefOptions{})
				},
			})
			return nil
		},
		Tooltip: self.c.Tr.CheckoutCommitTooltip,
		Key:     'd',
	})

	if len(branches) > 0 {
		menuItems = append(menuItems, lo.Map(branches, func(branch *models.Branch, index int) *types.MenuItem {
			return &types.MenuItem{
				LabelColumns: []string{self.c.Tr.Actions.CheckoutBranch, style.FgBlue.Sprint(branch.Name)},
				OnPress: func() error {
					self.c.LogAction(self.c.Tr.Actions.CheckoutBranch)
					return self.CheckoutRef(branch.RefName(), types.CheckoutRefOptions{})
				},
				Tooltip: self.c.Tr.CheckoutBranchTooltip,
				Key:     rune(index + 1 + '0'), // Convert 1-based index to key
			}
		})...)
	} else {
		menuItems = append(menuItems, &types.MenuItem{
			LabelColumns:   []string{self.c.Tr.Actions.CheckoutBranch},
			OnPress:        func() error { return nil },
			DisabledReason: &types.DisabledReason{Text: self.c.Tr.NoBranchesFoundAtCommitTooltip},
		})
	}

	return self.c.Menu(types.CreateMenuOptions{
		Title: self.c.Tr.Actions.CheckoutBranchOrCommit,
		Items: menuItems,
	})
}

func (self *RefsHelper) NewBranch(from string, fromFormattedName string, suggestedBranchName string) error {
	message := utils.ResolvePlaceholderString(

Review comment (suggestion):
I'd say it's a good idea to assign the `1` key to this, too, just so that it looks more similar to the real ones.

Code after:
		return commit.Hash == branch.CommitHash && branch.Name != self.c.Model().CheckedOutBranch
	})

	hash := commit.Hash
	var menuItems []*types.MenuItem

	if len(branches) > 0 {
		menuItems = append(menuItems, lo.Map(branches, func(branch *models.Branch, index int) *types.MenuItem {
			var key types.Key
			if index < 9 {
				key = rune(index + 1 + '0') // Convert 1-based index to key
			}
			return &types.MenuItem{
				LabelColumns: []string{fmt.Sprintf(self.c.Tr.Actions.CheckoutBranchAtCommit, branch.Name)},
				OnPress: func() error {
					self.c.LogAction(self.c.Tr.Actions.CheckoutBranch)
					return self.CheckoutRef(branch.RefName(), types.CheckoutRefOptions{})
				},
				Key: key,
			}
		})...)
	} else {
		menuItems = append(menuItems, &types.MenuItem{
			LabelColumns:   []string{self.c.Tr.Actions.CheckoutBranch},
			OnPress:        func() error { return nil },
			DisabledReason: &types.DisabledReason{Text: self.c.Tr.NoBranchesFoundAtCommitTooltip},
			Key:            '1',
		})
	}

	menuItems = append(menuItems, &types.MenuItem{
		LabelColumns: []string{fmt.Sprintf(self.c.Tr.Actions.CheckoutCommitAsDetachedHead, utils.ShortHash(hash))},
		OnPress: func() error {
			self.c.LogAction(self.c.Tr.Actions.CheckoutCommit)
			return self.CheckoutRef(hash, types.CheckoutRefOptions{})
		},
		Key: 'd',
	})

	return self.c.Menu(types.CreateMenuOptions{
		Title: self.c.Tr.Actions.CheckoutBranchOrCommit,
		Items: menuItems,
	})
}

func (self *RefsHelper) NewBranch(from string, fromFormattedName string, suggestedBranchName string) error {
	message := utils.ResolvePlaceholderString(
		self.c.Tr.NewBranchNameBranchOff,
		map[string]string{
			"branchName": fromFormattedName,
		},