Skip to content

Commit

Permalink
fix delta again
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseduffield committed Nov 22, 2021
1 parent 8abc953 commit 02bf6a5
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions pkg/gui/pty.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,24 @@ import (
"github.com/jesseduffield/gocui"
)

func (gui *Gui) desiredPtySize() *pty.Winsize {
width, height := gui.Views.Main.Size()

return &pty.Winsize{Cols: uint16(width), Rows: uint16(height)}
}

func (gui *Gui) onResize() error {
if gui.State.Ptmx == nil {
return nil
}
width, height := gui.Views.Main.Size()

if err := pty.Setsize(gui.State.Ptmx, &pty.Winsize{Cols: uint16(width), Rows: uint16(height)}); err != nil {
// TODO: handle resizing properly: we need to actually clear the main view
// and re-read the output from our pty. Or we could just re-run the original
// command from scratch
if err := pty.Setsize(gui.State.Ptmx, gui.desiredPtySize()); err != nil {
return err
}

// TODO: handle resizing properly

return nil
}

Expand Down Expand Up @@ -52,7 +58,7 @@ func (gui *Gui) newPtyTask(view *gocui.View, cmd *exec.Cmd, prefix string) error
manager := gui.getManager(view)

start := func() (*exec.Cmd, io.Reader) {
ptmx, err := pty.Start(cmd)
ptmx, err := pty.StartWithSize(cmd, gui.desiredPtySize())
if err != nil {
gui.Log.Error(err)
}
Expand All @@ -67,10 +73,6 @@ func (gui *Gui) newPtyTask(view *gocui.View, cmd *exec.Cmd, prefix string) error
gui.State.Ptmx = nil
}

if err := gui.onResize(); err != nil {
return err
}

if err := manager.NewTask(manager.NewCmdTask(start, prefix, height+oy+10, onClose), cmdStr); err != nil {
return err
}
Expand Down

0 comments on commit 02bf6a5

Please sign in to comment.