mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-24 07:25:20 -05:00
Let integration tests post a focus event
Lazygit reloads changed config files when its terminal window regains focus, but the test harness had no way to simulate that focus event, so the live config-reload path was untestable. Add a focus event to the replayed-events queue and expose it through the GuiDriver as FocusIn. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
922861bb36
commit
30559f1058
@@ -103,6 +103,7 @@ type replayedEvents struct {
|
||||
Keys chan *TcellKeyEventWrapper
|
||||
Resizes chan *TcellResizeEventWrapper
|
||||
MouseEvents chan *TcellMouseEventWrapper
|
||||
FocusEvents chan *TcellFocusEventWrapper
|
||||
}
|
||||
|
||||
type RecordingConfig struct {
|
||||
@@ -245,6 +246,7 @@ func NewGui(opts NewGuiOpts) (*Gui, error) {
|
||||
Keys: make(chan *TcellKeyEventWrapper),
|
||||
Resizes: make(chan *TcellResizeEventWrapper),
|
||||
MouseEvents: make(chan *TcellMouseEventWrapper),
|
||||
FocusEvents: make(chan *TcellFocusEventWrapper),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -266,6 +266,22 @@ func (wrapper TcellResizeEventWrapper) toTcellEvent() tcell.Event {
|
||||
return tcell.NewEventResize(wrapper.Width, wrapper.Height)
|
||||
}
|
||||
|
||||
type TcellFocusEventWrapper struct {
|
||||
Timestamp int64
|
||||
Focused bool
|
||||
}
|
||||
|
||||
func NewTcellFocusEventWrapper(event *tcell.EventFocus, timestamp int64) *TcellFocusEventWrapper {
|
||||
return &TcellFocusEventWrapper{
|
||||
Timestamp: timestamp,
|
||||
Focused: event.Focused,
|
||||
}
|
||||
}
|
||||
|
||||
func (wrapper TcellFocusEventWrapper) toTcellEvent() tcell.Event {
|
||||
return tcell.NewEventFocus(wrapper.Focused)
|
||||
}
|
||||
|
||||
// pollEvent get tcell.Event and transform it into gocuiEvent
|
||||
func (g *Gui) pollEvent() GocuiEvent {
|
||||
var tev tcell.Event
|
||||
@@ -277,6 +293,8 @@ func (g *Gui) pollEvent() GocuiEvent {
|
||||
tev = (ev).toTcellEvent()
|
||||
case ev := <-g.ReplayedEvents.MouseEvents:
|
||||
tev = (ev).toTcellEvent()
|
||||
case ev := <-g.ReplayedEvents.FocusEvents:
|
||||
tev = (ev).toTcellEvent()
|
||||
}
|
||||
} else {
|
||||
tev = <-Screen.EventQ()
|
||||
|
||||
Reference in New Issue
Block a user