Skip to content

Commit

Permalink
fix(tea): set the color profile once
Browse files Browse the repository at this point in the history
Set the global color profile once out of the middleware. We don't need
to set the value every time the middleware is called.
This also adds a comment about the behavior.
  • Loading branch information
aymanbagabas committed Jul 27, 2023
1 parent 0b49def commit bf81d93
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bubbletea/tea.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,11 @@ func MiddlewareWithColorProfile(bth Handler, cp termenv.Profile) wish.Middleware
// Make sure to set the tea.WithInput and tea.WithOutput to the ssh.Session
// otherwise the program will not function properly.
func MiddlewareWithProgramHandler(bth ProgramHandler, cp termenv.Profile) wish.Middleware {
// XXX: This is a hack to make sure the default Termenv output color
// profile is set before the program starts. Ideally, we want a Lip Gloss
// renderer per session.
lipgloss.SetColorProfile(cp)
return func(sh ssh.Handler) ssh.Handler {
lipgloss.SetColorProfile(cp)
return func(s ssh.Session) {
p := bth(s)
if p != nil {
Expand Down

0 comments on commit bf81d93

Please sign in to comment.