-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Prompt generally signals that the shell is ready #1900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
I don't think repeating And it looks like you did a bunch of additional refactorings here, which is nice, but it's a different concern, so it should be in a separate commit (or in a separate pull request). |
cbc277d
to
dcefbb0
Compare
👍 Will do: I've replaced |
test/test_go.rb
Outdated
tmux.send_keys '3d' | ||
tmux.until { |lines| lines[-3].end_with? 'echo 3rd' } | ||
tmux.until { |lines| lines[-3].end_with? 'echo 3d' } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you removed the additional CTRL-R for toggling sort and changed the assertions accordingly. Can you add checks for the toggling functionality? i.e. match_count
should be 2
and lines[-3]
should toggle between echo 3rd
and echo 3d
on CTRL-R.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️ Will do! But for the time being I've undone the changes.
test/test_go.rb
Outdated
# Keys are possibly echoed before the (fish) shell is ready for | ||
# C-r? In this case there's no other feedback to check for so add | ||
# an arbitrary delay. | ||
sleep 0.5 if shell == :fish |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to avoid this arbitrary delay. This seems to the case where the old Left, Right hack should work well. What do you think?
tmux.send_keys(query, :Left, :Right)
# $ foo^[[D^[[C (not ready)
# $ foo (ready)
tmux.until { |lines| lines[-1] == "$ #{query}" }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it! But I tried it out and the intermittent failure returned: https://travis-ci.org/jablko/fzf/jobs/657850503#L534
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the backtrace shows that it errored at test/test_go.rb:1842:in `block in test_ctrl_r_abort'
, which is: https://github.com/jablko/fzf/blob/28a39ddbc5a8761f151d8b05e3da4b92f98ad812/test/test_go.rb#L1842
So it sends query
(in this case a double quote) followed by :Left and :Right. It finds $ #{query}
(in this case $ "
) so determines that the shell should be ready! It sends C-r but fish still stumbles and doesn't launch fzf 🙍♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's strange. Let me see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use the equality condition (lines[-1] == "$ #{query}"
) instead of start_with?
which should return true before fish processes left and right arrow keys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this left-right dance turns out to work well, we probably should put it in tmux.prepare
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦♂️ Sorry I missed .start_with?
. Thanks for your patience! However there are still intermittent failures:
-
- https://travis-ci.org/junegunn/fzf/jobs/658740657#L635
Line 1793 in 191c308
tmux.until { |lines| lines[-1] == "> #{query}" }
I used lines[-1] != "$ #{query}^[[D^[[C"
or !lines[-1].start_with?("$ #{query}^")
instead of lines[-1] == "$ #{query}"
because fish sometimes offers an autocompletion: https://travis-ci.org/jablko/fzf/jobs/658726395#L628
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because fish sometimes offers an autocompletion
Hmm, this is painful. One thing I noticed on my machine is that I append a space after double-quote, the suggestion text disappears. So,
tmux.send_keys(query, :Space, :Left, :Right)
might simplify the check. But anyway, this trick doesn't seem to completely prevent fish from not responding on CTRL-R.
There are other test cases for CTRL-R, should we apply the same hack on those cases as well?
We used to wrap these key bindings with retries
method,
Lines 1758 to 1762 in d9c6a03
retries do tmux.prepare tmux.send_keys 'C-t' tmux.until { |lines| lines.item_count == 100 } end Lines 1839 to 1843 in d9c6a03
retries do tmux.prepare tmux.send_keys 'C-r' tmux.until { |lines| lines.match_count.positive? } end Lines 1820 to 1824 in d9c6a03
retries do tmux.prepare tmux.send_keys :Escape, :c tmux.until { |lines| lines.item_count == 1 } end
but you removed them all in this pull request. Maybe we should keep them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in those cases there's a prompt we can rely on instead?
test/test_go.rb
Outdated
tmux.send_keys 'sleep12345' | ||
tmux.until { |lines| lines.any_include? 'sleep 12345' } | ||
tmux.until { |lines| lines.match_count == 1 } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about changing this to lines.match_count >= 1
? We can't be 100% sure if our process is the only match on the system.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there's more than one match can we be sure we'll the right one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, but it will avoid false negatives. Any reason you decided to remove any_include?
which should be more robust in that regard? If we would really like to avoid false positives, we could generate a large random integer instead of 12345
and search for that number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, but it will avoid false negatives.
Sorry, I didn't think carefully enough! You're right: I've changed it to lines.match_count >= 1
👍
Any reason you decided to remove
any_include?
which should be more robust in that regard?
Is it more robust? It checks that the process is among the matches but another match might still be selected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not perfect, but I'm sure we can agree that it is better than not checking at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your point, how about lines[5].end_with?(' sleep 12345')
?
0ac07b3
to
5cdaf38
Compare
0e11d73
to
f3d6a30
Compare
I think I've fixed it: The loop below now runs for 50 minutes without failing (it exhausts the Travis CI job time limit): https://travis-ci.org/github/jablko/fzf/builds/670342136 Would you consider giving it another look? while ruby test/test_go.rb --verbose; do :; done |
I've rebased this change and confirmed that an indefinite loop still exhausts the job time limit without failing: https://travis-ci.org/github/jablko/fzf/builds/670732268 |
What do you think of this (hopefully) simplified
tmux.prepare
? (relying on the prompt to signal that the shell is ready)