mirror of
https://github.com/zoriya/bubbles.git
synced 2026-08-05 12:46:14 +00:00
chore!(cursor): improve naming around 'blinking'
This commit is contained in:
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
// TestBlinkCmdDataRace tests for a race on [Cursor.blinkTag].
|
||||
//
|
||||
// The original [Model.BlinkCmd] implementation returned a closure over the pointer receiver:
|
||||
// The original [Model.Blink] implementation returned a closure over the pointer receiver:
|
||||
//
|
||||
// return func() tea.Msg {
|
||||
// defer cancel()
|
||||
@@ -20,12 +20,12 @@ import (
|
||||
// }
|
||||
//
|
||||
// A race on “m.blinkTag” will occur if:
|
||||
// 1. [Model.BlinkCmd] is called e.g. by calling [Model.Focus] from
|
||||
// 1. [Model.Blink] is called e.g. by calling [Model.Focus] from
|
||||
// ["github.com/charmbracelet/bubbletea".Model.Update];
|
||||
// 2. ["github.com/charmbracelet/bubbletea".handleCommands] is kept sufficiently busy that it does not recieve and
|
||||
// execute the [Model.BlinkCmd] e.g. by other long running command or commands;
|
||||
// execute the [Model.Blink] e.g. by other long running command or commands;
|
||||
// 3. at least [Mode.BlinkSpeed] time elapses;
|
||||
// 4. [Model.BlinkCmd] is called again;
|
||||
// 4. [Model.Blink] is called again;
|
||||
// 5. ["github.com/charmbracelet/bubbletea".handleCommands] gets around to receiving and executing the original
|
||||
// closure.
|
||||
//
|
||||
@@ -33,7 +33,7 @@ import (
|
||||
// current value rather than the value at the time the closure was created).
|
||||
func TestBlinkCmdDataRace(t *testing.T) {
|
||||
m := New()
|
||||
cmd := m.BlinkCmd()
|
||||
cmd := m.Blink()
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(2)
|
||||
go func() {
|
||||
@@ -44,7 +44,7 @@ func TestBlinkCmdDataRace(t *testing.T) {
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
time.Sleep(m.BlinkSpeed * 2)
|
||||
m.BlinkCmd()
|
||||
m.Blink()
|
||||
}()
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user