diff --git a/internal/csync/slices_test.go b/internal/csync/slices_test.go index d838485e4865210d232c89e1531a191ce7d09418..fd1bd69ba6ca4d07cd5383cb52746e41caa8d901 100644 --- a/internal/csync/slices_test.go +++ b/internal/csync/slices_test.go @@ -98,7 +98,7 @@ func TestSlice(t *testing.T) { original := []int{1, 2, 3} s := NewSliceFrom(original) assert.Equal(t, 3, s.Len()) - + // Verify it's a copy, not a reference original[0] = 999 val, ok := s.Get(0) @@ -110,12 +110,12 @@ func TestSlice(t *testing.T) { s := NewSlice[string]() s.Append("hello") s.Append("world") - + assert.Equal(t, 2, s.Len()) val, ok := s.Get(0) require.True(t, ok) assert.Equal(t, "hello", val) - + val, ok = s.Get(1) require.True(t, ok) assert.Equal(t, "world", val) @@ -125,12 +125,12 @@ func TestSlice(t *testing.T) { s := NewSlice[string]() s.Append("world") s.Prepend("hello") - + assert.Equal(t, 2, s.Len()) val, ok := s.Get(0) require.True(t, ok) assert.Equal(t, "hello", val) - + val, ok = s.Get(1) require.True(t, ok) assert.Equal(t, "world", val) @@ -138,21 +138,21 @@ func TestSlice(t *testing.T) { t.Run("Delete", func(t *testing.T) { s := NewSliceFrom([]int{1, 2, 3, 4, 5}) - + // Delete middle element ok := s.Delete(2) assert.True(t, ok) assert.Equal(t, 4, s.Len()) - + expected := []int{1, 2, 4, 5} actual := s.Slice() assert.Equal(t, expected, actual) - + // Delete out of bounds ok = s.Delete(10) assert.False(t, ok) assert.Equal(t, 4, s.Len()) - + // Delete negative index ok = s.Delete(-1) assert.False(t, ok) @@ -161,15 +161,15 @@ func TestSlice(t *testing.T) { t.Run("Get", func(t *testing.T) { s := NewSliceFrom([]string{"a", "b", "c"}) - + val, ok := s.Get(1) require.True(t, ok) assert.Equal(t, "b", val) - + // Out of bounds _, ok = s.Get(10) assert.False(t, ok) - + // Negative index _, ok = s.Get(-1) assert.False(t, ok) @@ -177,18 +177,18 @@ func TestSlice(t *testing.T) { t.Run("Set", func(t *testing.T) { s := NewSliceFrom([]string{"a", "b", "c"}) - + ok := s.Set(1, "modified") assert.True(t, ok) - + val, ok := s.Get(1) require.True(t, ok) assert.Equal(t, "modified", val) - + // Out of bounds ok = s.Set(10, "invalid") assert.False(t, ok) - + // Negative index ok = s.Set(-1, "invalid") assert.False(t, ok) @@ -198,13 +198,13 @@ func TestSlice(t *testing.T) { s := NewSlice[int]() s.Append(1) s.Append(2) - + newItems := []int{10, 20, 30} s.SetSlice(newItems) - + assert.Equal(t, 3, s.Len()) assert.Equal(t, newItems, s.Slice()) - + // Verify it's a copy newItems[0] = 999 val, ok := s.Get(0) @@ -215,7 +215,7 @@ func TestSlice(t *testing.T) { t.Run("Clear", func(t *testing.T) { s := NewSliceFrom([]int{1, 2, 3}) assert.Equal(t, 3, s.Len()) - + s.Clear() assert.Equal(t, 0, s.Len()) }) @@ -223,10 +223,10 @@ func TestSlice(t *testing.T) { t.Run("Slice", func(t *testing.T) { original := []int{1, 2, 3} s := NewSliceFrom(original) - + copy := s.Slice() assert.Equal(t, original, copy) - + // Verify it's a copy copy[0] = 999 val, ok := s.Get(0) @@ -236,25 +236,25 @@ func TestSlice(t *testing.T) { t.Run("Seq", func(t *testing.T) { s := NewSliceFrom([]int{1, 2, 3}) - + var result []int for v := range s.Seq() { result = append(result, v) } - + assert.Equal(t, []int{1, 2, 3}, result) }) t.Run("SeqWithIndex", func(t *testing.T) { s := NewSliceFrom([]string{"a", "b", "c"}) - + var indices []int var values []string for i, v := range s.SeqWithIndex() { indices = append(indices, i) values = append(values, v) } - + assert.Equal(t, []int{0, 1, 2}, indices) assert.Equal(t, []string{"a", "b", "c"}, values) }) @@ -263,9 +263,9 @@ func TestSlice(t *testing.T) { s := NewSlice[int]() const numGoroutines = 100 const itemsPerGoroutine = 10 - + var wg sync.WaitGroup - + // Concurrent appends for i := 0; i < numGoroutines; i++ { wg.Add(1) @@ -276,7 +276,7 @@ func TestSlice(t *testing.T) { } }(i) } - + // Concurrent reads for i := 0; i < numGoroutines; i++ { wg.Add(1) @@ -287,9 +287,9 @@ func TestSlice(t *testing.T) { } }() } - + wg.Wait() - + // Should have all items assert.Equal(t, numGoroutines*itemsPerGoroutine, s.Len()) }) diff --git a/internal/tui/exp/list/filterable.go b/internal/tui/exp/list/filterable.go index 89930a905b162a7b470ab01588013da9577bf81c..909bcf8a42c728aea398bdc16794b63d7d6e725d 100644 --- a/internal/tui/exp/list/filterable.go +++ b/internal/tui/exp/list/filterable.go @@ -265,7 +265,7 @@ func (f *filterableList[T]) Filter(query string) tea.Cmd { matchedItems = append(matchedItems, item) } - if f.list.direction == DirectionBackward { + if f.direction == DirectionBackward { slices.Reverse(matchedItems) } diff --git a/internal/tui/exp/list/list.go b/internal/tui/exp/list/list.go index c3fec3000f86b0edac3debcc55644f1c10e11662..0d9c06cd920fb6c6671a0cba89acbee3912051ca 100644 --- a/internal/tui/exp/list/list.go +++ b/internal/tui/exp/list/list.go @@ -846,7 +846,6 @@ func (l *list[T]) SelectItemAbove() tea.Cmd { cmds = append(cmds, cmd) } } - } item, ok := l.items.Get(newIndex) if !ok {