mirror of
https://github.com/taigrr/bubbletea.git
synced 2026-04-02 02:59:09 -07:00
fix(output): reuse termenv output (#715)
If the passed io.Writer is a termenv.Output, use it instead of creating a new termenv.Output.
This commit is contained in:
@@ -28,7 +28,11 @@ func WithContext(ctx context.Context) ProgramOption {
|
|||||||
// won't need to use this.
|
// won't need to use this.
|
||||||
func WithOutput(output io.Writer) ProgramOption {
|
func WithOutput(output io.Writer) ProgramOption {
|
||||||
return func(p *Program) {
|
return func(p *Program) {
|
||||||
p.output = termenv.NewOutput(output, termenv.WithColorCache(true))
|
if o, ok := output.(*termenv.Output); ok {
|
||||||
|
p.output = o
|
||||||
|
} else {
|
||||||
|
p.output = termenv.NewOutput(output, termenv.WithColorCache(true))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user