Open
Description
Take this snippet as an example:
package main
import (
tea "github.com/charmbracelet/bubbletea/v2"
)
type model struct{}
func (m model) Init() tea.Cmd {
return nil
}
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch msg.String() {
case "q":
return m, tea.Quit
default:
return m, tea.Printf("Key pressed: %s", msg.String())
}
}
return m, nil
}
func (m model) View() string {
return `Logging stuff. Press "q" to exit.`
}
func main() {
p := tea.NewProgram(model{}, tea.WithAltScreen())
if _, err := p.Run(); err != nil {
panic(err)
}
}
Because we're using tea.WithAltScreen()
, the tea.Printf
instructions are no-op and are not been print at all. Because these are used for debugging, the user may believe that some other feature is not working while it's actually just the debugging logs not being print due to AltScreen.
Before releasing v2 for real, we may consider adding some errors or warning somehow if tea.Printf
is used together with tea.WithAltScreen()
. Even a panic
can be considered, but perhaps that's a bit too drastic?
Below, I'll paste the code paths until a return
is reached, preventing the print:
Lines 739 to 740 in 7858a14
Line 219 in 7858a14
/cc @aymanbagabas
Metadata
Metadata
Assignees
Labels
No labels