mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-23 12:18:51 +02:00
use ptmx map so that we can have multiple ptmx's stored for resizing
This commit is contained in:
parent
524bf83a4a
commit
54fb73080a
@ -90,6 +90,10 @@ type Gui struct {
|
|||||||
waitForIntro sync.WaitGroup
|
waitForIntro sync.WaitGroup
|
||||||
fileWatcher *fileWatcher
|
fileWatcher *fileWatcher
|
||||||
viewBufferManagerMap map[string]*tasks.ViewBufferManager
|
viewBufferManagerMap map[string]*tasks.ViewBufferManager
|
||||||
|
// 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{}
|
stopChan chan struct{}
|
||||||
|
|
||||||
// when lazygit is opened outside a git directory we want to open to the most
|
// when lazygit is opened outside a git directory we want to open to the most
|
||||||
@ -171,7 +175,6 @@ type GuiRepoState struct {
|
|||||||
|
|
||||||
IsRefreshingFiles bool
|
IsRefreshingFiles bool
|
||||||
Searching searchingState
|
Searching searchingState
|
||||||
Ptmx *os.File
|
|
||||||
StartupStage StartupStage // Allows us to not load everything at once
|
StartupStage StartupStage // Allows us to not load everything at once
|
||||||
|
|
||||||
ContextManager ContextManager
|
ContextManager ContextManager
|
||||||
@ -303,7 +306,6 @@ func (gui *Gui) resetState(startArgs types.StartArgs, reuseState bool) {
|
|||||||
UserVerticalScrolling: false,
|
UserVerticalScrolling: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Ptmx: nil,
|
|
||||||
Modes: &types.Modes{
|
Modes: &types.Modes{
|
||||||
Filtering: filtering.New(startArgs.FilterPath),
|
Filtering: filtering.New(startArgs.FilterPath),
|
||||||
CherryPicking: cherrypicking.New(),
|
CherryPicking: cherrypicking.New(),
|
||||||
@ -366,6 +368,7 @@ func NewGui(
|
|||||||
Updater: updater,
|
Updater: updater,
|
||||||
statusManager: &statusManager{},
|
statusManager: &statusManager{},
|
||||||
viewBufferManagerMap: map[string]*tasks.ViewBufferManager{},
|
viewBufferManagerMap: map[string]*tasks.ViewBufferManager{},
|
||||||
|
viewPtmxMap: map[string]*os.File{},
|
||||||
showRecentRepos: showRecentRepos,
|
showRecentRepos: showRecentRepos,
|
||||||
RepoPathStack: &utils.StringStack{},
|
RepoPathStack: &utils.StringStack{},
|
||||||
RepoStateMap: map[Repo]*GuiRepoState{},
|
RepoStateMap: map[Repo]*GuiRepoState{},
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
|
|
||||||
"github.com/creack/pty"
|
"github.com/creack/pty"
|
||||||
"github.com/jesseduffield/gocui"
|
"github.com/jesseduffield/gocui"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (gui *Gui) desiredPtySize() *pty.Winsize {
|
func (gui *Gui) desiredPtySize() *pty.Winsize {
|
||||||
@ -23,18 +24,13 @@ func (gui *Gui) onResize() error {
|
|||||||
gui.Mutexes.PtyMutex.Lock()
|
gui.Mutexes.PtyMutex.Lock()
|
||||||
defer gui.Mutexes.PtyMutex.Unlock()
|
defer gui.Mutexes.PtyMutex.Unlock()
|
||||||
|
|
||||||
if gui.State.Ptmx == nil {
|
for _, ptmx := range gui.viewPtmxMap {
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
gui.Log.Warn("resizing")
|
|
||||||
|
|
||||||
// TODO: handle resizing properly: we need to actually clear the main view
|
// 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
|
// and re-read the output from our pty. Or we could just re-run the original
|
||||||
// command from scratch
|
// command from scratch
|
||||||
if err := pty.Setsize(gui.State.Ptmx, gui.desiredPtySize()); err != nil {
|
if err := pty.Setsize(ptmx, gui.desiredPtySize()); err != nil {
|
||||||
panic(err)
|
return utils.WrapError(err)
|
||||||
return err
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -73,7 +69,7 @@ func (gui *Gui) newPtyTask(view *gocui.View, cmd *exec.Cmd, prefix string) error
|
|||||||
}
|
}
|
||||||
|
|
||||||
gui.Mutexes.PtyMutex.Lock()
|
gui.Mutexes.PtyMutex.Lock()
|
||||||
gui.State.Ptmx = ptmx
|
gui.viewPtmxMap[view.Name()] = ptmx
|
||||||
gui.Mutexes.PtyMutex.Unlock()
|
gui.Mutexes.PtyMutex.Unlock()
|
||||||
|
|
||||||
return cmd, ptmx
|
return cmd, ptmx
|
||||||
@ -82,8 +78,7 @@ func (gui *Gui) newPtyTask(view *gocui.View, cmd *exec.Cmd, prefix string) error
|
|||||||
onClose := func() {
|
onClose := func() {
|
||||||
gui.Mutexes.PtyMutex.Lock()
|
gui.Mutexes.PtyMutex.Lock()
|
||||||
ptmx.Close()
|
ptmx.Close()
|
||||||
ptmx = nil
|
delete(gui.viewPtmxMap, view.Name())
|
||||||
gui.State.Ptmx = nil
|
|
||||||
gui.Mutexes.PtyMutex.Unlock()
|
gui.Mutexes.PtyMutex.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user