mirror of
				https://github.com/zsh-users/zsh-autosuggestions.git
				synced 2024-05-11 05:54:57 +00:00 
			
		
		
		
	Fix handling of newline + carriage return in async pty (#333)
This commit is contained in:
		@@ -27,6 +27,45 @@ 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')
 | 
			
		||||
 | 
			
		||||
    session.clear_screen
 | 
			
		||||
 | 
			
		||||
    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)')
 | 
			
		||||
 
 | 
			
		||||
@@ -17,9 +17,12 @@ _zsh_autosuggest_async_server() {
 | 
			
		||||
		sleep 1 # Block for long enough for the signal to come through
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	# Output only newlines (not carriage return + newline)
 | 
			
		||||
	# Don't add any extra carriage returns
 | 
			
		||||
	stty -onlcr
 | 
			
		||||
 | 
			
		||||
	# Don't translate carriage returns to newlines
 | 
			
		||||
	stty -icrnl
 | 
			
		||||
 | 
			
		||||
	# Silence any error messages
 | 
			
		||||
	exec 2>/dev/null
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -595,9 +595,12 @@ _zsh_autosuggest_async_server() {
 | 
			
		||||
		sleep 1 # Block for long enough for the signal to come through
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	# Output only newlines (not carriage return + newline)
 | 
			
		||||
	# Don't add any extra carriage returns
 | 
			
		||||
	stty -onlcr
 | 
			
		||||
 | 
			
		||||
	# Don't translate carriage returns to newlines
 | 
			
		||||
	stty -icrnl
 | 
			
		||||
 | 
			
		||||
	# Silence any error messages
 | 
			
		||||
	exec 2>/dev/null
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user