charmbracelet/bubbletea (github.com/charmbracelet/bubbletea)
### [`v1.1.1`](https://redirect.github.com/charmbracelet/bubbletea/releases/tag/v1.1.1)
[Compare Source](https://redirect.github.com/charmbracelet/bubbletea/compare/v1.1.0...v1.1.1)
### Don't panic!
Panicking is a part of life…and a part of workin’ in Go. This release addresses two edge cases where a `panic()` could tank Bubble Tea and break your terminal:
#### Panics outside of Bubble Tea
If a panic occurs outside of Bubble Tea you can use [`Program.Kill`](https://pkg.go.dev/github.com/charmbracelet/bubbletea#Program.Kill) to restore the terminal state before exiting:
```go
func main() {
p := tea.NewProgram(model{})
go func() {
time.Sleep(3 * time.Second)
defer p.Kill()
panic("Urgh")
}()
if _, err := p.Run(); err != nil {
log.Fatal(err)
}
}
```
#### Panics in Cmds
If a panic occurs in a `Cmd` Bubble Tea will now automatically restore the terminal to its natural state before exiting.
```go
type model struct{}
// This command will totally panic.
func pancikyCmd() tea.Msg {
panic("Oh no! Jk.")
}
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch msg.String() {
case "enter":
// Panic time! But everything will be OK.
return m, pancikyCmd
}
}
return m, nil
}
```
Happy panicking (if that makes any sense).
#### Changelog
##### Fixed!
- [`0589921`](https://redirect.github.com/charmbracelet/bubbletea/commit/0589921d2e5a1ee33e0dba1d54836946e78fe059): fix: recover from panics within cmds ([@aymanbagabas](https://redirect.github.com/aymanbagabas))
- [`6e71f52`](https://redirect.github.com/charmbracelet/bubbletea/commit/6e71f52a8add0fdeba202d4e1bdd289182b156ac): fix: restore the terminal on kill ([@aymanbagabas](https://redirect.github.com/aymanbagabas))
***
Thoughts? Questions? We love hearing from you. Feel free to reach out on [Twitter](https://twitter.com/charmcli), [The Fediverse](https://mastodon.technology/@charm), or on [Discord](https://charm.sh/chat).
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
[ ] If you want to rebase/retry this PR, check this box
This PR contains the following updates:
v1.1.0
->v1.1.1
Release Notes
charmbracelet/bubbletea (github.com/charmbracelet/bubbletea)
### [`v1.1.1`](https://redirect.github.com/charmbracelet/bubbletea/releases/tag/v1.1.1) [Compare Source](https://redirect.github.com/charmbracelet/bubbletea/compare/v1.1.0...v1.1.1) ### Don't panic! Panicking is a part of life…and a part of workin’ in Go. This release addresses two edge cases where a `panic()` could tank Bubble Tea and break your terminal: #### Panics outside of Bubble Tea If a panic occurs outside of Bubble Tea you can use [`Program.Kill`](https://pkg.go.dev/github.com/charmbracelet/bubbletea#Program.Kill) to restore the terminal state before exiting: ```go func main() { p := tea.NewProgram(model{}) go func() { time.Sleep(3 * time.Second) defer p.Kill() panic("Urgh") }() if _, err := p.Run(); err != nil { log.Fatal(err) } } ``` #### Panics in Cmds If a panic occurs in a `Cmd` Bubble Tea will now automatically restore the terminal to its natural state before exiting. ```go type model struct{} // This command will totally panic. func pancikyCmd() tea.Msg { panic("Oh no! Jk.") } func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg := msg.(type) { case tea.KeyMsg: switch msg.String() { case "enter": // Panic time! But everything will be OK. return m, pancikyCmd } } return m, nil } ``` Happy panicking (if that makes any sense). #### Changelog ##### Fixed! - [`0589921`](https://redirect.github.com/charmbracelet/bubbletea/commit/0589921d2e5a1ee33e0dba1d54836946e78fe059): fix: recover from panics within cmds ([@aymanbagabas](https://redirect.github.com/aymanbagabas)) - [`6e71f52`](https://redirect.github.com/charmbracelet/bubbletea/commit/6e71f52a8add0fdeba202d4e1bdd289182b156ac): fix: restore the terminal on kill ([@aymanbagabas](https://redirect.github.com/aymanbagabas)) *** Thoughts? Questions? We love hearing from you. Feel free to reach out on [Twitter](https://twitter.com/charmcli), [The Fediverse](https://mastodon.technology/@charm), or on [Discord](https://charm.sh/chat).Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.