Files
lazygit/pkg/gui/controllers/diffing_menu_action.go
Stefan HallerandClaude Opus 4.8 88811e6795 Remove the RefreshMode field
With sync vs async now derived from the calling thread, the Mode field
and its SYNC/ASYNC constants no longer carry any information: Refresh is
always async, RefreshFromWorker always sync. Drop the field, the type,
and the Mode argument at every call site, and reduce the debug log's
mode name to a plain sync/async derived from calledFromWorker.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-17 12:32:32 +02:00

74 lines
1.7 KiB
Go

package controllers
import (
"fmt"
"github.com/jesseduffield/lazygit/pkg/gui/modes/diffing"
"github.com/jesseduffield/lazygit/pkg/gui/types"
)
type DiffingMenuAction struct {
c *ControllerCommon
}
func (self *DiffingMenuAction) Call() error {
names := self.c.Helpers().Diff.CurrentDiffTerminals()
menuItems := []*types.MenuItem{}
for _, name := range names {
menuItems = append(menuItems, []*types.MenuItem{
{
Label: fmt.Sprintf("%s %s", self.c.Tr.Diff, name),
OnPress: func() error {
self.c.Modes().Diffing.Ref = name
// can scope this down based on current view but too lazy right now
self.c.Refresh(types.RefreshOptions{})
return nil
},
},
}...)
}
menuItems = append(menuItems, []*types.MenuItem{
{
Label: self.c.Tr.EnterRefToDiff,
OnPress: func() error {
self.c.Prompt(types.PromptOpts{
Title: self.c.Tr.EnterRefName,
FindSuggestionsFunc: self.c.Helpers().Suggestions.GetRefsSuggestionsFunc(),
HandleConfirm: func(response string) error {
self.c.Modes().Diffing.Ref = response
self.c.Refresh(types.RefreshOptions{})
return nil
},
})
return nil
},
},
}...)
if self.c.Modes().Diffing.Active() {
menuItems = append(menuItems, []*types.MenuItem{
{
Label: self.c.Tr.SwapDiff,
OnPress: func() error {
self.c.Modes().Diffing.Reverse = !self.c.Modes().Diffing.Reverse
self.c.Refresh(types.RefreshOptions{})
return nil
},
},
{
Label: self.c.Tr.ExitDiffMode,
OnPress: func() error {
self.c.Modes().Diffing = diffing.New()
self.c.Refresh(types.RefreshOptions{})
return nil
},
},
}...)
}
return self.c.Menu(types.CreateMenuOptions{Title: self.c.Tr.DiffingMenuTitle, Items: menuItems})
}