This repository was archived by the owner on Aug 30, 2024. It is now read-only.
File tree 3 files changed +9
-0
lines changed
3 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -5,12 +5,14 @@ import (
5
5
"io"
6
6
"os"
7
7
"os/signal"
8
+ "time"
8
9
9
10
"github.com/spf13/pflag"
10
11
"go.coder.com/cli"
11
12
"go.coder.com/flog"
12
13
"golang.org/x/crypto/ssh/terminal"
13
14
"golang.org/x/sys/unix"
15
+ "golang.org/x/time/rate"
14
16
15
17
client "cdr.dev/coder-cli/internal/entclient"
16
18
"cdr.dev/coder-cli/wush"
@@ -39,6 +41,9 @@ func (cmd *shellCmd) sendResizeEvents(termfd int, client *wush.Client) {
39
41
sigs := make (chan os.Signal , 16 )
40
42
signal .Notify (sigs , unix .SIGWINCH )
41
43
44
+ // Limit the frequency of resizes to prevent a stuttering effect.
45
+ resizeLimiter := rate .NewLimiter (rate .Every (time .Millisecond * 100 ), 1 )
46
+
42
47
for {
43
48
width , height , err := terminal .GetSize (termfd )
44
49
if err != nil {
@@ -51,8 +56,10 @@ func (cmd *shellCmd) sendResizeEvents(termfd int, client *wush.Client) {
51
56
flog .Error ("get term size: %v" , err )
52
57
return
53
58
}
59
+
54
60
// Do this last so the first resize is sent.
55
61
<- sigs
62
+ resizeLimiter .Wait (context .Background ())
56
63
}
57
64
}
58
65
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ require (
16
16
golang.org/x/crypto v0.0.0-20200422194213-44a606286825
17
17
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a
18
18
golang.org/x/sys v0.0.0-20200413165638-669c56c373c4
19
+ golang.org/x/time v0.0.0-20191024005414-555d28b269f0
19
20
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543
20
21
nhooyr.io/websocket v1.8.5
21
22
)
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7w
59
59
golang.org/x/sys v0.0.0-20200413165638-669c56c373c4 h1:opSr2sbRXk5X5/givKrrKj9HXxFpW2sdCiP8MJSKLQY =
60
60
golang.org/x/sys v0.0.0-20200413165638-669c56c373c4 /go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs =
61
61
golang.org/x/text v0.3.0 /go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ =
62
+ golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs =
62
63
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 /go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ =
63
64
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4 =
64
65
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 /go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0 =
You can’t perform that action at this time.
0 commit comments