Skip to content

Commit

Permalink
fix(renderer): use termenv default renderer
Browse files Browse the repository at this point in the history
Creating a _new_ global termenv output clashes with the default global
termenv output leading the terminal to block and freeze.
Share the default termenv output with the global default lipgloss renderer.
  • Loading branch information
aymanbagabas authored and muesli committed Mar 9, 2023
1 parent 19ca9a3 commit 7f47f0b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions renderer.go
Expand Up @@ -2,12 +2,15 @@ package lipgloss

import (
"io"
"os"

"github.com/muesli/termenv"
)

var renderer = NewRenderer(os.Stdout)
// We're manually creating the struct here to avoid initializing the output and
// query the terminal multiple times.
var renderer = &Renderer{
output: termenv.DefaultOutput(),
}

// Renderer is a lipgloss terminal renderer.
type Renderer struct {
Expand Down
2 changes: 1 addition & 1 deletion style.go
Expand Up @@ -173,7 +173,7 @@ func (s Style) Inherit(i Style) Style {
// Render applies the defined style formatting to a given string.
func (s Style) Render(strs ...string) string {
if s.r == nil {
s.r = DefaultRenderer()
s.r = renderer
}
if s.value != "" {
strs = append([]string{s.value}, strs...)
Expand Down

0 comments on commit 7f47f0b

Please sign in to comment.