Skip to content

Commit

Permalink
fix: put pty slave in raw mode before querying (#351)
Browse files Browse the repository at this point in the history
fixes #350
  • Loading branch information
caarlos0 authored Oct 29, 2024
1 parent 8699d8b commit 85d7557
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion bubbletea/tea_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/charmbracelet/ssh"
"github.com/charmbracelet/x/ansi"
"github.com/charmbracelet/x/input"
"github.com/charmbracelet/x/term"
"github.com/lucasb-eyer/go-colorful"
"github.com/muesli/termenv"
)
Expand Down Expand Up @@ -45,7 +46,11 @@ func newRenderer(s ssh.Session) *lipgloss.Renderer {
termenv.WithEnvironment(env),
termenv.WithColorCache(true),
)
bg, _ = queryBackgroundColor(pty.Slave, pty.Slave)
state, err := term.MakeRaw(pty.Slave.Fd())
if err == nil {
bg, _ = queryBackgroundColor(pty.Slave, pty.Slave)
term.Restore(pty.Slave.Fd(), state)

Check failure on line 52 in bubbletea/tea_unix.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `term.Restore` is not checked (errcheck)
}
} else {
r = lipgloss.NewRenderer(
s,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
github.com/charmbracelet/ssh v0.0.0-20240725163421-eb71b85b27aa
github.com/charmbracelet/x/ansi v0.4.0
github.com/charmbracelet/x/input v0.2.0
github.com/charmbracelet/x/term v0.2.0
github.com/go-git/go-git/v5 v5.12.0
github.com/google/go-cmp v0.6.0
github.com/hashicorp/golang-lru/v2 v2.0.7
Expand All @@ -29,7 +30,6 @@ require (
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/charmbracelet/x/conpty v0.1.0 // indirect
github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86 // indirect
github.com/charmbracelet/x/term v0.2.0 // indirect
github.com/charmbracelet/x/termios v0.1.0 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/creack/pty v1.1.21 // indirect
Expand Down

0 comments on commit 85d7557

Please sign in to comment.