You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The Context() method only passes the context to the underlying bubbletea program. If you set the Spinner to use Accessible mode then the context isn't used.
Also worth noting, even though Run() returns an error, it is not possible to have a non-nil error:
// runAccessible runs the spinner in an accessible mode (statically).
func (s*Spinner) runAccessible() error {
s.output.HideCursor()
frame:=s.spinner.Style.Render("...")
title:=s.titleStyle.Render(s.title)
fmt.Println(title+frame)
s.action()
s.output.ShowCursor()
s.output.CursorBack(len(frame) +len(title))
returnnil
}
So I do see the expected behavior of fast cancellation on context cancellation, just with no error. But when in Accessible mode the context is ignored.
@maaslalani with your change, note that there is an inconsistency between run which won't run the action if a context is set, and runAccessible, which always run the action.
I believe run should always run the action as well, even if a context is set. My take is that it would make the spinner easier to use. It would also help return proper errors.
For instance, we could set a flag when CTRL+C is pressed, and return an error on p.Quit() in this case.
Yeah you're correct @testinfected, I think if the action is provided we should run it and if it's not we should simply wait until the context is cancelled on both TUI and accessible mode.
Describe the bug
The
Context()
method only passes the context to the underlying bubbletea program. If you set the Spinner to use Accessible mode then the context isn't used.Also worth noting, even though
Run()
returns an error, it is not possible to have a non-nil error:huh/spinner/spinner.go
Lines 138 to 169 in acfe24c
So I do see the expected behavior of fast cancellation on context cancellation, just with no error. But when in Accessible mode the context is ignored.
To Reproduce
Steps to reproduce the behavior:
https://go.dev/play/p/MTobz4rLf7t
Expected behavior
Run()
returns a context.Cancelled error typeAccessible(true)
still handles context cancellationDesktop (please complete the following information):
N/A
Smartphone (please complete the following information):
N/A
The text was updated successfully, but these errors were encountered: