summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-08-06 11:48:08 +1000
committerJesse Duffield <jessedduffield@gmail.com>2022-08-06 13:49:11 +1000
commit54fb73080a6f925065a320e5e5d049b6a72a4629 (patch)
tree3e911c9575324d98e4bca4d7965411b9b6577f3f /pkg
parent524bf83a4a681408c3fb57818f6968cab632e0ae (diff)
use ptmx map so that we can have multiple ptmx's stored for resizing
Diffstat (limited to 'pkg')
-rw-r--r--pkg/gui/gui.go9
-rw-r--r--pkg/gui/pty.go25
2 files changed, 16 insertions, 18 deletions
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index b903fa662..908cede2e 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -90,7 +90,11 @@ type Gui struct {
waitForIntro sync.WaitGroup
fileWatcher *fileWatcher
viewBufferManagerMap map[string]*tasks.ViewBufferManager
- stopChan chan struct{}
+ // holds a mapping of view names to ptmx's. This is for rendering command outputs
+ // from within a pty. The point of keeping track of them is so that if we re-size
+ // the window, we can tell the pty it needs to resize accordingly.
+ viewPtmxMap map[string]*os.File
+ stopChan chan struct{}
// when lazygit is opened outside a git directory we want to open to the most
// recent repo with the recent repos popup showing
@@ -171,7 +175,6 @@ type GuiRepoState struct {
IsRefreshingFiles bool
Searching searchingState
- Ptmx *os.File
StartupStage StartupStage // Allows us to not load everything at once
ContextManager ContextManager
@@ -303,7 +306,6 @@ func (gui *Gui) resetState(startArgs types.StartArgs, reuseState bool) {
UserVerticalScrolling: false,
},
},
- Ptmx: nil,
Modes: &types.Modes{
Filtering: filtering.New(startArgs.FilterPath),
CherryPicking: cherrypicking.New(),
@@ -366,6 +368,7 @@ func NewGui(
Updater: updater,
statusManager: &statusManager{},
viewBufferManagerMap: map[string]*tasks.ViewBufferManager{},
+ viewPtmxMap: map[string]*os.File{},
showRecentRepos: showRecentRepos,
RepoPathStack: &utils.StringStack{},
RepoStateMap: map[Repo]*GuiRepoState{},
diff --git a/pkg/gui/pty.go b/pkg/gui/pty.go
index d0ff891e4..4a87c98da 100644
--- a/pkg/gui/pty.go
+++ b/pkg/gui/pty.go
@@ -11,6 +11,7 @@ import (
"github.com/creack/pty"
"github.com/jesseduffield/gocui"
+ "github.com/jesseduffield/lazygit/pkg/utils"
)
func (gui *Gui) desiredPtySize() *pty.Winsize {
@@ -23,18 +24,13 @@ func (gui *Gui) onResize() error {
gui.Mutexes.PtyMutex.Lock()
defer gui.Mutexes.PtyMutex.Unlock()
- if gui.State.Ptmx == nil {
- return nil
- }
-
- gui.Log.Warn("resizing")
-
- // 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 {
- panic(err)
- return err
+ for _, ptmx := range gui.viewPtmxMap {
+ // 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(ptmx, gui.desiredPtySize()); err != nil {
+ return utils.WrapError(err)
+ }
}
return nil
@@ -73,7 +69,7 @@ func (gui *Gui) newPtyTask(view *gocui.View, cmd *exec.Cmd, prefix string) error
}
gui.Mutexes.PtyMutex.Lock()
- gui.State.Ptmx = ptmx
+ gui.viewPtmxMap[view.Name()] = ptmx
gui.Mutexes.PtyMutex.Unlock()
return cmd, ptmx
@@ -82,8 +78,7 @@ func (gui *Gui) newPtyTask(view *gocui.View, cmd *exec.Cmd, prefix string) error
onClose := func() {
gui.Mutexes.PtyMutex.Lock()
ptmx.Close()
- ptmx = nil
- gui.State.Ptmx = nil
+ delete(gui.viewPtmxMap, view.Name())
gui.Mutexes.PtyMutex.Unlock()
}