Skip to content

Commit

Permalink
fix: several bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
cfoust committed Nov 9, 2023
1 parent d1fc43f commit 7b706bb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/fuzzy/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (f *Fuzzy) Update(msg tea.Msg) (taro.Model, tea.Cmd) {
f.selected = geom.Clamp(f.selected+delta, 0, len(f.getOptions())-1)
return f, f.handlePreview()
case taro.KeyEnter:
if f.selected < len(f.getOptions()) {
if f.selected >= 0 && f.selected < len(f.getOptions()) {
option := f.getOptions()[f.selected]
f.result <- option.Result
} else {
Expand Down
7 changes: 5 additions & 2 deletions pkg/util/pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ func NewPublisher[T any]() *Publisher[T] {
}

func (p *Publisher[T]) Publish(value T) {
subscribers := make([]*Subscriber[T], 0)
p.m.Lock()
subscribers := p.subscribers
for subscriber := range p.subscribers {
subscribers = append(subscribers, subscriber)
}
p.m.Unlock()

for subscriber := range subscribers {
for _, subscriber := range subscribers {
subscriber.m.RLock()
active := subscriber.active
subscriber.m.RUnlock()
Expand Down

0 comments on commit 7b706bb

Please sign in to comment.