Fix focus event not triggered in certain cases
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 b92a843 · Browse files · 2 files·+12 added−5 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+12 added−5 removed
- tests:+4 added−0 removed
- other:+8 added−5 removed
Provenance
- Commit
e47dc75- Tree
e21c001- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
b92a843
2 files changed+12 added−5 removed
modified:src/terminal.go+8 added-5 removed
249 unmodified lines250 pwindow tui.Window251 borderWidth int252 count int253 progress int254+ hasFocusActions bool255 hasLoadActions bool256 triggerLoad bool257 reading bool258 running bool471 unmodified lines730 header0: opts.Header,731 ellipsis: opts.Ellipsis,732 ansi: opts.Ansi,733 tabstop: opts.Tabstop,734+ hasFocusActions: false,735 hasLoadActions: false,736 triggerLoad: false,737 reading: true,738 running: true,19 unmodified lines758 startChan: make(chan fitpad, 1),759 killChan: make(chan int),760 serverInputChan: make(chan []*action, 10),761 serverOutputChan: make(chan string),760- eventChan: make(chan tui.Event, 3), // load / zero|one | GetChar762+ eventChan: make(chan tui.Event, 4), // (load + zero|one) | (focus) | (GetChar)763 tui: renderer,764 initFunc: func() { renderer.Init() },765 executing: util.NewAtomicBool(false),766 lastAction: actStart,35 unmodified lines802 }803 }804 }805 806+ _, t.hasFocusActions = t.keymap[tui.Focus.AsEvent()]807 _, t.hasLoadActions = t.keymap[tui.Load.AsEvent()]808 809 if t.listenAddr != nil {810 err, port := startHttpServer(*t.listenAddr, t.serverInputChan, t.serverOutputChan)2261 unmodified lines3072 if focusChanged && t.track == trackCurrent {3073 t.track = trackDisabled3074 t.printInfo()3075 }3073- if onFocus, prs := t.keymap[tui.Focus.AsEvent()]; prs && focusChanged && currentIndex != t.lastFocus {3074- t.lastFocus = focusedIndex3075- t.serverInputChan <- onFocus3076+ if t.hasFocusActions && focusChanged && currentIndex != t.lastFocus {3077+ t.lastFocus = currentIndex3078+ t.eventChan <- tui.Focus.AsEvent()3079 }3080 if focusChanged || version != t.version {3081 version = t.version3082 focusedIndex = currentIndex105 unmodified lines3188 barrier <- true3189 }3190 select {3191 case event = <-t.eventChan:3189- needBarrier = !event.Is(tui.Load, tui.One, tui.Zero)3192+ needBarrier = !event.Is(tui.Load, tui.Focus, tui.One, tui.Zero)3193 case serverActions := <-t.serverInputChan:3194 event = tui.Invalid.AsEvent()3195 if t.listenAddr == nil || t.listenAddr.IsLocal() || t.listenUnsafe {3196 actions = serverActions965 unmodified linesmodified:test/test_go.rb+4 added
2709 unmodified lines2710 tmux.send_keys :Up2711 tmux.until { |lines| assert_includes(lines[-1], '[[2]]') }2712 tmux.send_keys :X2713 tmux.until { |lines| assert_includes(lines[-1], '[[]]') }2714+ tmux.send_keys :BSpace2715+ tmux.until { |lines| assert_includes(lines[-1], '[[1]]') }2716+ tmux.send_keys :X2717+ tmux.until { |lines| assert_includes(lines[-1], '[[]]') }2718 tmux.send_keys '?'2719 tmux.send_keys :BSpace2720 tmux.until { |lines| assert_equal 100, lines.match_count }2721 tmux.until { |lines| refute_includes(lines[-1], '[[1]]') }867 unmodified lines