Skip to content

Commit

Permalink
fix: do not make raw terminal on windows
Browse files Browse the repository at this point in the history
apparently windows does not handle it very well... and it seems to not
be needed for windows either way.

closes #102

Signed-off-by: Carlos Alexandro Becker <[email protected]>
  • Loading branch information
caarlos0 committed Nov 15, 2023
1 parent 995aff2 commit 9583789
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions client_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os/signal"
"os/user"
"path/filepath"
"runtime"

tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/log"
Expand Down Expand Up @@ -117,16 +118,18 @@ func (s *localSession) Run() error {
}

log.Info("requesting tty")
originalState, err := term.MakeRaw(fd)
if err != nil {
return fmt.Errorf("failed get terminal state: %w", err)
}

defer func() {
if err := term.Restore(fd, originalState); err != nil {
log.Warn("couldn't restore terminal state", "err", err)
if runtime.GOOS != "windows" {
originalState, err := term.MakeRaw(fd)
if err != nil {
return fmt.Errorf("failed get terminal state: %w", err)
}
}()

defer func() {
if err := term.Restore(fd, originalState); err != nil {
log.Warn("couldn't restore terminal state", "err", err)
}
}()
}

w, h, err := term.GetSize(fd)
if err != nil {
Expand Down

0 comments on commit 9583789

Please sign in to comment.