Skip to content
Myr

Limit the maximum number of focus events to process at once

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Junegunn Choi · committed by Junegunn Choi · parent 091b7ea · Browse files · 1 file+16 added−9 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+16 added−9 removed

  • other:+16 added−9 removed

1 file+16 added−9 removed

modified:src/terminal.go+16 added-9 removed
53 unmodified lines
54var actionTypeRegex *regexp.Regexp5556const clearCode string = "\x1b[2J"5758// Number of maximum focus events to process synchronously59const maxFocusEvents = 100006061func init() {62 placeholder = regexp.MustCompile(`\\?(?:{[+sf]*[0-9,-.]*}|{q}|{fzf:(?:query|action|prompt)}|{\+?f?nf?})`)63 whiteSuffix = regexp.MustCompile(`\s*$`)64 offsetComponentRegex = regexp.MustCompile(`([+-][0-9]+)|(-?/[1-9][0-9]*)`)
3242 unmodified lines
33073308 var doAction func(*action) bool3309 var doActions func(actions []*action) bool3310 doActions = func(actions []*action) bool {3311 for iter := 0; iter <= maxFocusEvents; iter++ {3308 currentIndex := t.currentIndex()3309 for _, action := range actions {3310 if !doAction(action) {3311 return false3312 currentIndex := t.currentIndex()3313 for _, action := range actions {3314 if !doAction(action) {3315 return false3316 }3317 }3313 }33183315 if onFocus, prs := t.keymap[tui.Focus.AsEvent()]; prs {3316 if newIndex := t.currentIndex(); newIndex != currentIndex {3317 t.lastFocus = newIndex3318 return doActions(onFocus)3319 if onFocus, prs := t.keymap[tui.Focus.AsEvent()]; prs && iter < maxFocusEvents {3320 if newIndex := t.currentIndex(); newIndex != currentIndex {3321 t.lastFocus = newIndex3322 actions = onFocus3323 continue3324 }3325 }3326 break3327 }3328 return true3329 }3330 doAction = func(a *action) bool {
894 unmodified lines