Skip to content
Myr

Pass bracketed paste actions through wait/track block

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

A pasted character firing a wait-arming binding swallowed the subsequent bracketed-paste-end, leaving t.pasting set forever and suppressing queryChanged for all later input. Let paste begin/end through the block so pasting state is maintained and the search for the edited query is dispatched.

authored by Junegunn Choi · committed by Junegunn Choi · parent 743930a · Browse files · 3 files+26 added−3 removed
This commit

State

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

Diff stats

3 files+26 added−3 removed

  • tests:+20 added−0 removed
  • other:+6 added−3 removed

3 files+26 added−3 removed

modified:src/terminal.go+6 added-3 removed
5836 unmodified lines
58375838// The wait state machine. Invariant: arming captures every action after5839// 'wait' at any nesting level into wait.pending; while blocked, actions are5840// dropped unless they are results of work started before the block5841// (bg-transform callbacks); abort/cancel discards everything.5841// (bg-transform callbacks, bracketed paste bookkeeping); abort/cancel5842// discards everything.58435844// blockWait blocks action execution and defers the given actions until the5845// current search completes (see UpdateList)5846func (t *Terminal) blockWait(pending []*action) {
957 unmodified lines
6804 }6805 }6806 // Actions that run even while wait/track-blocked: bg-transform6807 // callbacks and their parsed actions (results of processes6807 // started before the block).6808 passthrough := inBgCallback || a.t == actAsync6808 // started before the block), and bracketed paste bookkeeping (a6809 // swallowed paste-end would leave t.pasting set forever).6810 passthrough := inBgCallback || a.t == actAsync ||6811 a.t == actBracketedPasteBegin || a.t == actBracketedPasteEnd6812 // When wait-blocked, only allow abort/cancel6813 if t.wait.blocked && !passthrough {6814 if a.t == actAbort || a.t == actCancel {6815 t.cancelWait()
1750 unmodified lines
modified:test/lib/common.rb+6 added
175 unmodified lines
176 def paste(str)177 system('tmux', 'setb', str, ';', 'pasteb', '-t', win, ';', 'send-keys', '-t', win, 'Enter')178 end179180 # Paste with bracketed paste control codes so fzf sees181 # bracketed-paste-begin/end around the content182 def paste_bracketed(str)183 system('tmux', 'setb', str, ';', 'pasteb', '-p', '-t', win)184 end185186 def capture187 go(%W[capture-pane -p -J -t #{win}]).map(&:rstrip).reverse.drop_while(&:empty?).reverse188 end189
209 unmodified lines
modified:test/test_core.rb+14 added
1249 unmodified lines
1250 tmux.send_keys 'a'1251 tmux.until { |lines| assert_equal '> 5', lines[-3] }1252 end12531254 def test_wait_action_bracketed_paste1255 # A wait armed by a binding fired from a pasted character must not break1256 # bracketed paste handling: paste-end passes through the block so1257 # t.pasting is cleared and the pending search is dispatched1258 tmux.send_keys %(seq 100 | #{FZF} --bind 'a:put(a)+wait+first'), :Enter1259 tmux.until { |lines| assert_equal 100, lines.match_count }1260 tmux.paste_bracketed('1a2')1261 # Search for the edited query must run; blocked forever before the fix1262 tmux.until { |lines| assert_equal 0, lines.match_count }1263 # Filtering must still work afterwards1264 tmux.send_keys 'C-u', '55'1265 tmux.until { |lines| assert_equal 1, lines.match_count }1266 end12671268 def test_wait_action_expect1269 # --expect keys are ignored while wait-blocked, like the rest of the input1270 tmux.send_keys %((seq 100; sleep 2) | #{fzf('--expect ctrl-t --bind start:wait')}), :Enter1271 tmux.until { |lines| assert lines.any_include?('(..)') }
1686 unmodified lines