Skip to content

Commit

Permalink
close input channel when receiving io.EOF
Browse files Browse the repository at this point in the history
  • Loading branch information
jmorganca committed Oct 28, 2023
1 parent 4748609 commit 2d75a45
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
1 change: 0 additions & 1 deletion cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,6 @@ func generateInteractive(cmd *cobra.Command, model string) error {
if err != nil {
return err
}
defer scanner.Close()

var wordWrap bool
termType := os.Getenv("TERM")
Expand Down
9 changes: 1 addition & 8 deletions readline/readline.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,6 @@ func (i *Instance) Readline() (string, error) {
}
}

func (i *Instance) Close() {
i.Terminal.Close()
}

func (i *Instance) HistoryEnable() {
i.History.Enabled = true
}
Expand All @@ -239,6 +235,7 @@ func (t *Terminal) ioloop() {
for {
r, _, err := buf.ReadRune()
if err != nil {
close(t.outchan)
break
}
t.outchan <- r
Expand All @@ -253,7 +250,3 @@ func (t *Terminal) Read() (rune, error) {

return r, nil
}

func (t *Terminal) Close() {
close(t.outchan)
}

0 comments on commit 2d75a45

Please sign in to comment.