From 30f94c1c78ddb076074712812b566d7a72946330 Mon Sep 17 00:00:00 2001 From: David Dworken Date: Thu, 28 Dec 2023 19:24:51 -0800 Subject: [PATCH] Fix broken custom color scheme support as reported in #134 --- client/tui/tui.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/client/tui/tui.go b/client/tui/tui.go index 9efc233..ab1b7e4 100644 --- a/client/tui/tui.go +++ b/client/tui/tui.go @@ -812,6 +812,24 @@ func TuiQuery(ctx context.Context, initialQuery string) error { // test environments behave the same (by default, github actions // ubuntu and macos have different termenv support). lipgloss.SetColorProfile(termenv.ANSI) + } else { + // When the shell launches control-R it isn't hooked up to the main TTY, + // which means that termenv isn't able to accurately detect color support + // in the current terminal. This means we have to guess the right option, + // where we risk either: + // * Choosing too high of a color support, and breaking hishtory colors + // in certain terminals + // * Choosing too low of a color support, and ending up with truncating + // customized colors + // + // This is a tough situation with no right answer (as far as I can tell). + // The default terminal app on MacOS only supports termenv.ANSI256 (8 bit + // colors), which means we likely shouldn't default to TrueColor. From + // my own digging, I can't find any modern terminals that don't support + // termenv.ANSI256, so it seems like a reasonable default here. + // + // TODO: In the long term, we may want to make this configurable. + lipgloss.SetColorProfile(termenv.ANSI256) } p := tea.NewProgram(initialModel(ctx, initialQuery), tea.WithOutput(os.Stderr)) // Async: Get the initial set of rows