mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-10 23:57:43 +02:00
Fix PTY layout problems (#3658)
- **PR Description** This fixes two layout problems with pagers that draw a horizontal line across the entire width of the view (e.g. delta): - sometimes the width of that line was one character too long or too short in the staged changes view - when changing from a file or directory that has only staged or only unstaged changes to one that has both, the length of the horizontal line was totally off and only redraw correctly at the next refresh
This commit is contained in:
commit
b2c457366a
@ -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 {
|
func (gui *Gui) getWindowDimensions(informationStr string, appStatus string) map[string]boxlayout.Dimensions {
|
||||||
return gui.helpers.WindowArrangement.GetWindowDimensions(informationStr, appStatus)
|
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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -189,12 +189,7 @@ func (self *guiCommon) GetInitialKeybindingsWithCustomCommands() ([]*types.Bindi
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *guiCommon) AfterLayout(f func() error) {
|
func (self *guiCommon) AfterLayout(f func() error) {
|
||||||
select {
|
self.gui.afterLayout(f)
|
||||||
case self.gui.afterLayoutFuncs <- f:
|
|
||||||
default:
|
|
||||||
// hopefully this never happens
|
|
||||||
self.gui.c.Log.Error("afterLayoutFuncs channel is full, skipping function")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *guiCommon) RunningIntegrationTest() bool {
|
func (self *guiCommon) RunningIntegrationTest() bool {
|
||||||
|
@ -20,7 +20,10 @@ func (gui *Gui) runTaskForView(view *gocui.View, task types.UpdateTask) error {
|
|||||||
return gui.newCmdTask(view, v.Cmd, v.Prefix)
|
return gui.newCmdTask(view, v.Cmd, v.Prefix)
|
||||||
|
|
||||||
case *types.RunPtyTask:
|
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
|
return nil
|
||||||
|
@ -15,8 +15,8 @@ import (
|
|||||||
"github.com/samber/lo"
|
"github.com/samber/lo"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (gui *Gui) desiredPtySize() *pty.Winsize {
|
func (gui *Gui) desiredPtySize(view *gocui.View) *pty.Winsize {
|
||||||
width, height := gui.Views.Main.Size()
|
width, height := view.Size()
|
||||||
|
|
||||||
return &pty.Winsize{Cols: uint16(width), Rows: uint16(height)}
|
return &pty.Winsize{Cols: uint16(width), Rows: uint16(height)}
|
||||||
}
|
}
|
||||||
@ -25,11 +25,12 @@ func (gui *Gui) onResize() error {
|
|||||||
gui.Mutexes.PtyMutex.Lock()
|
gui.Mutexes.PtyMutex.Lock()
|
||||||
defer gui.Mutexes.PtyMutex.Unlock()
|
defer gui.Mutexes.PtyMutex.Unlock()
|
||||||
|
|
||||||
for _, ptmx := range gui.viewPtmxMap {
|
for viewName, ptmx := range gui.viewPtmxMap {
|
||||||
// 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(ptmx, gui.desiredPtySize()); err != nil {
|
view, _ := gui.g.View(viewName)
|
||||||
|
if err := pty.Setsize(ptmx, gui.desiredPtySize(view)); err != nil {
|
||||||
return utils.WrapError(err)
|
return utils.WrapError(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -44,7 +45,7 @@ func (gui *Gui) onResize() error {
|
|||||||
// pseudo-terminal meaning we'll get the behaviour we want from the underlying
|
// pseudo-terminal meaning we'll get the behaviour we want from the underlying
|
||||||
// command.
|
// command.
|
||||||
func (gui *Gui) newPtyTask(view *gocui.View, cmd *exec.Cmd, prefix string) error {
|
func (gui *Gui) newPtyTask(view *gocui.View, cmd *exec.Cmd, prefix string) error {
|
||||||
width, _ := gui.Views.Main.Size()
|
width, _ := view.Size()
|
||||||
pager := gui.git.Config.GetPager(width)
|
pager := gui.git.Config.GetPager(width)
|
||||||
externalDiffCommand := gui.Config.GetUserConfig().Git.Paging.ExternalDiffCommand
|
externalDiffCommand := gui.Config.GetUserConfig().Git.Paging.ExternalDiffCommand
|
||||||
|
|
||||||
@ -69,7 +70,7 @@ func (gui *Gui) newPtyTask(view *gocui.View, cmd *exec.Cmd, prefix string) error
|
|||||||
var ptmx *os.File
|
var ptmx *os.File
|
||||||
start := func() (*exec.Cmd, io.Reader) {
|
start := func() (*exec.Cmd, io.Reader) {
|
||||||
var err error
|
var err error
|
||||||
ptmx, err = pty.StartWithSize(cmd, gui.desiredPtySize())
|
ptmx, err = pty.StartWithSize(cmd, gui.desiredPtySize(view))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
gui.c.Log.Error(err)
|
gui.c.Log.Error(err)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user