Skip to content

Commit

Permalink
Fix "random" ANSI spew/UI hang
Browse files Browse the repository at this point in the history
It turns out that there is a lipgloss/termenv/bubbletea/reality
incompatibility when querying the background color. By querying this once
at the start before bubbletea takes control of the terminal, this can be
avoided.

See charmbracelet/lipgloss#73 (comment) for details.
  • Loading branch information
DavidS-ovm committed Jun 3, 2024
1 parent 86af0ec commit d84f8c6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 1 addition & 2 deletions cmd/theme.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/charmbracelet/glamour"
"github.com/charmbracelet/glamour/ansi"
"github.com/charmbracelet/lipgloss"
"github.com/muesli/termenv"
)

type LogoPalette struct {
Expand Down Expand Up @@ -175,7 +174,7 @@ func MarkdownStyle() ansi.StyleConfig {
var labelMuted string
var labelTitle string

if termenv.HasDarkBackground() {
if lipgloss.HasDarkBackground() {
bgBase = ColorPalette.BgBase.Dark
bgMain = ColorPalette.BgMain.Dark
labelBase = ColorPalette.LabelBase.Dark
Expand Down
10 changes: 9 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
package main

import "github.com/overmindtech/cli/cmd"
import (
"github.com/charmbracelet/lipgloss"
"github.com/muesli/termenv"
"github.com/overmindtech/cli/cmd"
)

func main() {
// work around lipgloss/termenv integration bug.
// See https://github.com/charmbracelet/lipgloss/issues/73#issuecomment-1144921037
lipgloss.SetHasDarkBackground(termenv.HasDarkBackground())

cmd.Execute()
}

0 comments on commit d84f8c6

Please sign in to comment.