Skip to content

Commit 7f47f0b

Browse files
aymanbagabasmuesli
authored andcommitted
fix(renderer): use termenv default renderer
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.
1 parent 19ca9a3 commit 7f47f0b

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

renderer.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ package lipgloss
22

33
import (
44
"io"
5-
"os"
65

76
"github.com/muesli/termenv"
87
)
98

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

1215
// Renderer is a lipgloss terminal renderer.
1316
type Renderer struct {

style.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func (s Style) Inherit(i Style) Style {
173173
// Render applies the defined style formatting to a given string.
174174
func (s Style) Render(strs ...string) string {
175175
if s.r == nil {
176-
s.r = DefaultRenderer()
176+
s.r = renderer
177177
}
178178
if s.value != "" {
179179
strs = append([]string{s.value}, strs...)

0 commit comments

Comments
 (0)