fix repl arrow bug
This commit is contained in:
6
go.mod
6
go.mod
@@ -3,12 +3,14 @@ module github.com/LazyBachelor/LazyPM
|
||||
go 1.26.1
|
||||
|
||||
require (
|
||||
github.com/c-bata/go-prompt v0.2.6
|
||||
github.com/go-git/go-git/v6 v6.0.0-20260317113930-fb0d09929504
|
||||
github.com/joho/godotenv v1.5.1
|
||||
github.com/muesli/reflow v0.3.0
|
||||
github.com/spf13/pflag v1.0.10
|
||||
github.com/steveyegge/beads v0.49.6
|
||||
go.mongodb.org/mongo-driver/v2 v2.5.0
|
||||
golang.org/x/term v0.41.0
|
||||
)
|
||||
|
||||
// Terminal dependencies
|
||||
@@ -18,9 +20,7 @@ require (
|
||||
charm.land/fang/v2 v2.0.1
|
||||
charm.land/huh/v2 v2.0.3
|
||||
charm.land/lipgloss/v2 v2.0.2
|
||||
github.com/c-bata/go-prompt v0.2.6
|
||||
github.com/spf13/cobra v1.10.2
|
||||
golang.org/x/term v0.41.0
|
||||
)
|
||||
|
||||
// Web dependencies
|
||||
@@ -78,7 +78,7 @@ require (
|
||||
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.21 // indirect
|
||||
github.com/mattn/go-tty v0.0.7 // indirect
|
||||
github.com/mattn/go-tty v0.0.3 // indirect
|
||||
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
|
||||
github.com/muesli/cancelreader v0.2.2 // indirect
|
||||
github.com/muesli/mango v0.2.0 // indirect
|
||||
|
||||
3
go.sum
3
go.sum
@@ -160,9 +160,8 @@ github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m
|
||||
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
|
||||
github.com/mattn/go-runewidth v0.0.21 h1:jJKAZiQH+2mIinzCJIaIG9Be1+0NR+5sz/lYEEjdM8w=
|
||||
github.com/mattn/go-runewidth v0.0.21/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
|
||||
github.com/mattn/go-tty v0.0.3 h1:5OfyWorkyO7xP52Mq7tB36ajHDG5OHrmBGIS/DtakQI=
|
||||
github.com/mattn/go-tty v0.0.3/go.mod h1:ihxohKRERHTVzN+aSVRwACLCeqIoZAWpoICkkvrWyR0=
|
||||
github.com/mattn/go-tty v0.0.7 h1:KJ486B6qI8+wBO7kQxYgmmEFDaFEE96JMBQ7h400N8Q=
|
||||
github.com/mattn/go-tty v0.0.7/go.mod h1:f2i5ZOvXBU/tCABmLmOfzLz9azMo5wdAaElRNnJKr+k=
|
||||
github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4=
|
||||
github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE=
|
||||
github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
|
||||
|
||||
@@ -52,14 +52,11 @@ func (r *REPL) Run(ctx context.Context, config app.Config) error {
|
||||
r.currentFeedback = ValidationFeedback{}
|
||||
r.completionChan = make(chan struct{}, 1)
|
||||
|
||||
// Set terminal to raw mode to capture input properly in the REPL.
|
||||
// This allows us to handle input character by character and provide a better user experience.
|
||||
// We also ensure that the terminal state is restored when the REPL exits, even if an error occurs.
|
||||
// Save terminal state to restore on exit (go-prompt v0.2.6 doesn't restore properly)
|
||||
oldState, err := term.GetState(int(os.Stdin.Fd()))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get terminal state: %w", err)
|
||||
if err == nil {
|
||||
defer term.Restore(int(os.Stdin.Fd()), oldState)
|
||||
}
|
||||
defer term.Restore(int(os.Stdin.Fd()), oldState)
|
||||
|
||||
// Initialize services for beads, config and stats.
|
||||
app, cleanup, err := app.New(ctx, config)
|
||||
@@ -114,7 +111,10 @@ replLoop:
|
||||
case <-r.completionChan:
|
||||
fmt.Println(style.TitleStyle.Render("Task completed successfully!"))
|
||||
fmt.Print("Press Enter to exit...")
|
||||
term.Restore(int(os.Stdin.Fd()), oldState)
|
||||
// Restore terminal before reading final input (go-prompt doesn't restore properly)
|
||||
if oldState != nil {
|
||||
term.Restore(int(os.Stdin.Fd()), oldState)
|
||||
}
|
||||
reader.ReadString('\n')
|
||||
break replLoop
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user