1package ui23import (4 "time"56 tea "charm.land/bubbletea/v2"7)89// No unit test waits on the clock (after). There's no terminal to say10// its background, so the model's wait for it is over at once; notebooks11// ask about the text being edited, and the word at the caret, once12// typing pauses, and the clock hands the message the pause would give13// to run, which keeps it in pauses: a test that wants a pause over ends14// it with endPauses.15func init() {16 after = func(_ time.Duration, msg tea.Msg) tea.Cmd {17 if _, ok := msg.(bgWaitedMsg); ok {18 return func() tea.Msg { return msg }19 }20 return func() tea.Msg { return pausedMsg{msg} }21 }22}2324// pausedMsg is a message a notebook asked for once typing pauses.25type pausedMsg struct{ msg tea.Msg }2627// pauses are the messages waiting for typing's pauses to end.28var pauses []tea.Msg2930// endPauses ends the pauses waiting, and those they start: the31// notebook asks about the text and the word at the caret, and m gets32// the answers.33func endPauses(m *Model) {34 for i := 0; i < 10 && len(pauses) > 0; i++ {35 msgs := pauses36 pauses = nil37 for _, msg := range msgs {38 send(m, msg)39 }40 }41}