handleResizing spawns a goroutine that processes the resize channel, calling resizeFunc for each remotecommand.TerminalSize received from the channel.
(ctx context.Context, resize <-chan remotecommand.TerminalSize, resizeFunc func(size remotecommand.TerminalSize))
| 77 | // handleResizing spawns a goroutine that processes the resize channel, calling resizeFunc for each |
| 78 | // remotecommand.TerminalSize received from the channel. |
| 79 | func handleResizing(ctx context.Context, resize <-chan remotecommand.TerminalSize, resizeFunc func(size remotecommand.TerminalSize)) { |
| 80 | if resize == nil { |
| 81 | return |
| 82 | } |
| 83 | |
| 84 | go func() { |
| 85 | defer runtime.HandleCrash() |
| 86 | |
| 87 | for { |
| 88 | select { |
| 89 | case <-ctx.Done(): |
| 90 | return |
| 91 | case size, ok := <-resize: |
| 92 | if !ok { |
| 93 | return |
| 94 | } |
| 95 | if size.Height < 1 || size.Width < 1 { |
| 96 | continue |
| 97 | } |
| 98 | resizeFunc(size) |
| 99 | } |
| 100 | } |
| 101 | }() |
| 102 | } |
no test coverage detected
searching dependent graphs…