mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-25 08:31:03 +00:00
resolve issue regarding the need to press enter when attached
This commit is contained in:
parent
4da06790a9
commit
ec5f96a1eb
1 changed files with 21 additions and 2 deletions
|
|
@ -380,8 +380,19 @@ func (c *Container) Attach() error {
|
||||||
|
|
||||||
channel := make(chan os.Signal, 1)
|
channel := make(chan os.Signal, 1)
|
||||||
signal.Notify(channel, syscall.SIGWINCH)
|
signal.Notify(channel, syscall.SIGWINCH)
|
||||||
|
|
||||||
// initial resize
|
// initial resize
|
||||||
|
//
|
||||||
|
// without this user needs to manually resize terminal,
|
||||||
|
// to get the prompt under cursor
|
||||||
|
//
|
||||||
|
// terminal width and height is artificially incremented
|
||||||
|
// and then it returns to nominal size
|
||||||
channel <- syscall.SIGWINCH
|
channel <- syscall.SIGWINCH
|
||||||
|
err = c.Resize(fd, true)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// read output from container
|
// read output from container
|
||||||
go func() {
|
go func() {
|
||||||
|
|
@ -410,7 +421,7 @@ func (c *Container) Attach() error {
|
||||||
for {
|
for {
|
||||||
sig := <-channel
|
sig := <-channel
|
||||||
if sig == syscall.SIGWINCH {
|
if sig == syscall.SIGWINCH {
|
||||||
err := c.Resize(fd)
|
err := c.Resize(fd, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -425,7 +436,10 @@ func (c *Container) Attach() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Container) Resize(fd uintptr) error {
|
// Resize gets current terminal size and sends it to Docker.
|
||||||
|
//
|
||||||
|
// Bool "fool" parameter if set to true increments height and width by 1.
|
||||||
|
func (c *Container) Resize(fd uintptr, fool bool) error {
|
||||||
size, err := term.GetWinsize(fd)
|
size, err := term.GetWinsize(fd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -436,6 +450,11 @@ func (c *Container) Resize(fd uintptr) error {
|
||||||
Width: uint(size.Width),
|
Width: uint(size.Width),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if fool {
|
||||||
|
options.Width++
|
||||||
|
options.Height++
|
||||||
|
}
|
||||||
|
|
||||||
err = c.Client.ContainerResize(context.Background(), c.ID, options)
|
err = c.Client.ContainerResize(context.Background(), c.ID, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue