Skip to content

Commit

Permalink
Run PTY tasks after layout so that they get the correct view size
Browse files Browse the repository at this point in the history
This is important when using a pager that draws a horizontal line across the
entire width of the view; when changing from a file or directory that has only
unstaged (or only staged) changes to one that has both, the main view is split
in half, but the PTY task would be run on the view in its old state, so the
horizonal line would be too long and wrap around.
  • Loading branch information
stefanhaller committed Jun 23, 2024
1 parent f98da78 commit 8b8343b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
9 changes: 9 additions & 0 deletions pkg/gui/gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -959,3 +959,12 @@ func (gui *Gui) onWorker(f func(gocui.Task) error) {
func (gui *Gui) getWindowDimensions(informationStr string, appStatus string) map[string]boxlayout.Dimensions {
return gui.helpers.WindowArrangement.GetWindowDimensions(informationStr, appStatus)
}

func (gui *Gui) afterLayout(f func() error) {
select {
case gui.afterLayoutFuncs <- f:
default:
// hopefully this never happens
gui.c.Log.Error("afterLayoutFuncs channel is full, skipping function")
}
}
7 changes: 1 addition & 6 deletions pkg/gui/gui_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,7 @@ func (self *guiCommon) GetInitialKeybindingsWithCustomCommands() ([]*types.Bindi
}

func (self *guiCommon) AfterLayout(f func() error) {
select {
case self.gui.afterLayoutFuncs <- f:
default:
// hopefully this never happens
self.gui.c.Log.Error("afterLayoutFuncs channel is full, skipping function")
}
self.gui.afterLayout(f)
}

func (self *guiCommon) RunningIntegrationTest() bool {
Expand Down
5 changes: 4 additions & 1 deletion pkg/gui/main_panels.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ func (gui *Gui) runTaskForView(view *gocui.View, task types.UpdateTask) error {
return gui.newCmdTask(view, v.Cmd, v.Prefix)

case *types.RunPtyTask:
return gui.newPtyTask(view, v.Cmd, v.Prefix)
gui.afterLayout(func() error {
return gui.newPtyTask(view, v.Cmd, v.Prefix)
})
return nil
}

return nil
Expand Down

0 comments on commit 8b8343b

Please sign in to comment.