mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2024-05-11 05:54:57 +00:00
Refactor async mode to no longer use zpty
See technique used in `fast-syntax-highlighting`:
- ca2e18bbc9
- http://www.zsh.org/mla/users/2018/msg00424.html
Also see http://www.zsh.org/mla/users/2018/msg00432.html
In async response handler:
- We only want to read data in case of POLLIN or POLLHUP. Not POLLNVAL
or select error.
- We always want to remove the handler, so it doesn't get called in an
infinite loop when error is nval or err.
There is an upstream bug that prevents ctrl-c from resetting the prompt
immediately after a suggestion has been fetched asynchronously. A patch
has been submitted, but a workaround for now is to add `command true`
after the exec.
See https://github.com/zsh-users/zsh-autosuggestions/issues/364
This commit is contained in:
@@ -1,8 +1,4 @@
|
||||
context 'with asynchronous suggestions enabled' do
|
||||
before do
|
||||
skip 'Async mode not supported below v5.0.8' if session.zsh_version < Gem::Version.new('5.0.8')
|
||||
end
|
||||
|
||||
let(:options) { ["ZSH_AUTOSUGGEST_USE_ASYNC="] }
|
||||
|
||||
describe '`up-line-or-beginning-search`' do
|
||||
@@ -31,52 +27,19 @@ context 'with asynchronous suggestions enabled' do
|
||||
end
|
||||
end
|
||||
|
||||
it 'should not add extra carriage returns before newlines' do
|
||||
session.
|
||||
send_string('echo "').
|
||||
send_keys('escape').
|
||||
send_keys('enter').
|
||||
send_string('"').
|
||||
send_keys('enter')
|
||||
describe 'pressing ^C after fetching a suggestion' do
|
||||
before do
|
||||
skip 'Workaround does not work below v5.0.8' if session.zsh_version < Gem::Version.new('5.0.8')
|
||||
end
|
||||
|
||||
session.clear_screen
|
||||
it 'terminates the prompt and begins a new one' do
|
||||
session.send_keys('e')
|
||||
sleep 0.1
|
||||
session.send_keys('C-c')
|
||||
sleep 0.1
|
||||
session.send_keys('echo')
|
||||
|
||||
session.send_string('echo')
|
||||
wait_for { session.content }.to eq("echo \"\n\"")
|
||||
end
|
||||
|
||||
it 'should treat carriage returns and newlines as separate characters' do
|
||||
session.
|
||||
send_string('echo "').
|
||||
send_keys('C-v').
|
||||
send_keys('enter').
|
||||
send_string('foo"').
|
||||
send_keys('enter')
|
||||
|
||||
session.
|
||||
send_string('echo "').
|
||||
send_keys('control').
|
||||
send_keys('enter').
|
||||
send_string('bar"').
|
||||
send_keys('enter')
|
||||
|
||||
session.clear_screen
|
||||
|
||||
session.
|
||||
send_string('echo "').
|
||||
send_keys('C-v').
|
||||
send_keys('enter')
|
||||
|
||||
wait_for { session.content }.to eq('echo "^Mfoo"')
|
||||
end
|
||||
|
||||
describe 'exiting a subshell' do
|
||||
it 'should not cause error messages to be printed' do
|
||||
session.run_command('$(exit)')
|
||||
|
||||
sleep 1
|
||||
|
||||
expect(session.content).to eq('$(exit)')
|
||||
wait_for { session.content }.to eq("e\necho")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user