diff --git a/filepicker/filepicker.go b/filepicker/filepicker.go index 4b6f5acf..86aaad01 100644 --- a/filepicker/filepicker.go +++ b/filepicker/filepicker.go @@ -233,8 +233,8 @@ func (m Model) Height() int { } // Init initializes the file picker model. -func (m Model) Init() (Model, tea.Cmd) { - return m, m.readDir(m.CurrentDirectory, m.ShowHidden) +func (m Model) Init() tea.Cmd { + return m.readDir(m.CurrentDirectory, m.ShowHidden) } // Update handles user interactions within the file picker model. diff --git a/go.mod b/go.mod index 43f6df2f..aa3c9a0b 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.18 require ( github.com/MakeNowJust/heredoc v1.0.0 github.com/atotto/clipboard v0.1.4 - github.com/charmbracelet/bubbletea/v2 v2.0.0-alpha.2.0.20250203222705-2e91ec2235cd + github.com/charmbracelet/bubbletea/v2 v2.0.0-alpha.2.0.20250204175057-2a96bc438da6 github.com/charmbracelet/harmonica v0.2.0 github.com/charmbracelet/lipgloss/v2 v2.0.0-alpha.2.0.20250204145343-96725424379d github.com/charmbracelet/x/ansi v0.8.0 diff --git a/go.sum b/go.sum index 27bba77b..07c14970 100644 --- a/go.sum +++ b/go.sum @@ -7,6 +7,8 @@ github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWp github.com/aymanbagabas/go-udiff v0.2.0/go.mod h1:RE4Ex0qsGkTAJoQdQQCA0uG+nAzJO/pI/QwceO5fgrA= github.com/charmbracelet/bubbletea/v2 v2.0.0-alpha.2.0.20250203222705-2e91ec2235cd h1:u+kqgSbIL4pnP7huv4kaYUCmuN2L4yyDvdH81QJ4FZ0= github.com/charmbracelet/bubbletea/v2 v2.0.0-alpha.2.0.20250203222705-2e91ec2235cd/go.mod h1:zaWGYfO6cBtu4dRgGbVN7yMYUz3j9sVIzHy2gn0jdo8= +github.com/charmbracelet/bubbletea/v2 v2.0.0-alpha.2.0.20250204175057-2a96bc438da6 h1:KbLqbYgHC5JZWks50WjBJr92Hs+GpiauwZaDObw9vxE= +github.com/charmbracelet/bubbletea/v2 v2.0.0-alpha.2.0.20250204175057-2a96bc438da6/go.mod h1:zaWGYfO6cBtu4dRgGbVN7yMYUz3j9sVIzHy2gn0jdo8= github.com/charmbracelet/colorprofile v0.2.0 h1:iiIQlp3LSvoJPtR11KoDfIf9wqWm2mn/iU420rHOZ/A= github.com/charmbracelet/colorprofile v0.2.0/go.mod h1:6wPrSSR4QtwYtOY3h0bLRw5YOUAIKWlZIJ02CTAsZsk= github.com/charmbracelet/harmonica v0.2.0 h1:8NxJWRWg/bzKqqEaaeFNipOu77YR5t8aSwG4pgaUBiQ= diff --git a/progress/progress.go b/progress/progress.go index 512aaa8d..10aa9f05 100644 --- a/progress/progress.go +++ b/progress/progress.go @@ -182,8 +182,8 @@ func New(opts ...Option) Model { } // Init exists to satisfy the tea.Model interface. -func (m Model) Init() (Model, tea.Cmd) { - return m, nil +func (m Model) Init() tea.Cmd { + return nil } // Update is used to animate the progress bar during transitions. Use diff --git a/stopwatch/stopwatch.go b/stopwatch/stopwatch.go index 3c79a917..89f36d2b 100644 --- a/stopwatch/stopwatch.go +++ b/stopwatch/stopwatch.go @@ -80,8 +80,8 @@ func (m Model) ID() int { } // Init starts the stopwatch. -func (m Model) Init() (Model, tea.Cmd) { - return m, m.Start() +func (m Model) Init() tea.Cmd { + return m.Start() } // Start starts the stopwatch. diff --git a/table/table_test.go b/table/table_test.go index 8c6da372..cfe87807 100644 --- a/table/table_test.go +++ b/table/table_test.go @@ -1,6 +1,7 @@ package table import ( + "strings" "testing" "github.com/charmbracelet/lipgloss/v2" @@ -124,7 +125,7 @@ func TestTableAlignment(t *testing.T) { {"Hobnobs", "UK", "Yes"}, }), ) - got := ansi.Strip(biscuits.View()) + got := ansiStrip(biscuits.View()) golden.RequireEqual(t, []byte(got)) }) t.Run("With border", func(t *testing.T) { @@ -153,7 +154,13 @@ func TestTableAlignment(t *testing.T) { }), WithStyles(s), ) - got := ansi.Strip(baseStyle.Render(biscuits.View())) + got := ansiStrip(baseStyle.Render(biscuits.View())) golden.RequireEqual(t, []byte(got)) }) } + +func ansiStrip(s string) string { + // Replace all \r\n with \n + s = strings.ReplaceAll(s, "\r\n", "\n") + return ansi.Strip(s) +} diff --git a/timer/timer.go b/timer/timer.go index 22c13ae4..c8e3bf3d 100644 --- a/timer/timer.go +++ b/timer/timer.go @@ -134,8 +134,8 @@ func (m Model) Timedout() bool { } // Init starts the timer. -func (m Model) Init() (Model, tea.Cmd) { - return m, m.tick() +func (m Model) Init() tea.Cmd { + return m.tick() } // Update handles the timer tick. diff --git a/viewport/viewport.go b/viewport/viewport.go index 5e6c68e3..8ac13ea9 100644 --- a/viewport/viewport.go +++ b/viewport/viewport.go @@ -145,8 +145,8 @@ func (m *Model) setInitialValues() { } // Init exists to satisfy the tea.Model interface for composability purposes. -func (m Model) Init() (Model, tea.Cmd) { - return m, nil +func (m Model) Init() tea.Cmd { + return nil } // Height returns the height of the viewport.