Skip to content

Commit

Permalink
Merge branch 'completion-timeout'
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Nov 22, 2013
2 parents efda092 + 68a43f9 commit a894445
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions features/support/completion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,22 +116,37 @@ def tmux_send_keys(*keys)
system(*($tmux + ['send-keys', '-t', tmux_pane, *keys]))
end

def tmux_send_tab
@last_pane_contents = tmux_pane_contents
tmux_send_keys('Tab')
end

def tmux_kill_pane
system(*($tmux + ['kill-pane', '-t', tmux_pane])) if tmux_pane?
end

def tmux_wait_for_prompt
num_waited = 0
while tmux_pane_contents !~ /\$\Z/
raise "timeout while waiting for shell prompt" if num_waited > 300
sleep 0.01
num_waited += 1
raise "timeout while waiting for shell prompt" if num_waited > 150
end
end

def tmux_wait_for_completion
# bash can be pretty slow
sleep 1
num_waited = 0
raise "tmux_send_tab not called first" unless defined? @last_pane_contents
while tmux_pane_contents == @last_pane_contents
if num_waited > 300
if block_given? then return yield
else
raise "timeout while waiting for completions to expand"
end
end
sleep 0.01
num_waited += 1
end
end

def tmux_completion_menu
Expand Down Expand Up @@ -181,11 +196,11 @@ def tmux_completion_menu_basic
tmux_wait_for_prompt
@last_command = string
tmux_send_keys(string)
tmux_send_keys('Tab')
tmux_send_tab
end

When(/^I press <Tab> again$/) do
tmux_send_keys('Tab')
tmux_send_tab
end

Then(/^the completion menu should offer "([^"]+?)"( unsorted)?$/) do |items, unsorted|
Expand Down

0 comments on commit a894445

Please sign in to comment.