From 56c40cbccc324c4a6365926fbf5bc3e0e4d84f63 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Mon, 13 May 2024 16:32:35 -0400 Subject: [PATCH] fix: use background ctx --- cursor/cursor.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cursor/cursor.go b/cursor/cursor.go index dd93e5c..84a84bd 100644 --- a/cursor/cursor.go +++ b/cursor/cursor.go @@ -2,6 +2,7 @@ package cursor import ( "context" + "errors" "time" tea "github.com/charmbracelet/bubbletea" @@ -163,7 +164,7 @@ func (m *Model) BlinkCmd() tea.Cmd { 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.blinkTag++ @@ -171,7 +172,7 @@ func (m *Model) BlinkCmd() tea.Cmd { return func() tea.Msg { defer cancel() <-ctx.Done() - if ctx.Err() == context.DeadlineExceeded { + if errors.Is(ctx.Err(), context.DeadlineExceeded) { return BlinkMsg{id: m.id, tag: m.blinkTag} } return blinkCanceled{}