mirror of
https://github.com/zoriya/bubbles.git
synced 2026-08-16 01:43:21 +00:00
fix: use background ctx
This commit is contained in:
+3
-2
@@ -2,6 +2,7 @@ package cursor
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
tea "github.com/charmbracelet/bubbletea"
|
tea "github.com/charmbracelet/bubbletea"
|
||||||
@@ -163,7 +164,7 @@ func (m *Model) BlinkCmd() tea.Cmd {
|
|||||||
m.blinkCtx.cancel()
|
m.blinkCtx.cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(m.blinkCtx.ctx, m.BlinkSpeed)
|
ctx, cancel := context.WithTimeout(context.Background(), m.BlinkSpeed)
|
||||||
m.blinkCtx.cancel = cancel
|
m.blinkCtx.cancel = cancel
|
||||||
|
|
||||||
m.blinkTag++
|
m.blinkTag++
|
||||||
@@ -171,7 +172,7 @@ func (m *Model) BlinkCmd() tea.Cmd {
|
|||||||
return func() tea.Msg {
|
return func() tea.Msg {
|
||||||
defer cancel()
|
defer cancel()
|
||||||
<-ctx.Done()
|
<-ctx.Done()
|
||||||
if ctx.Err() == context.DeadlineExceeded {
|
if errors.Is(ctx.Err(), context.DeadlineExceeded) {
|
||||||
return BlinkMsg{id: m.id, tag: m.blinkTag}
|
return BlinkMsg{id: m.id, tag: m.blinkTag}
|
||||||
}
|
}
|
||||||
return blinkCanceled{}
|
return blinkCanceled{}
|
||||||
|
|||||||
Reference in New Issue
Block a user