mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 09:44:31 +00:00 
			
		
		
		
	fix(system): don't treat NUL at start as no input (#34167)
This commit is contained in:
		@@ -856,7 +856,7 @@ static int do_os_system(char **argv, const char *input, size_t len, char **outpu
 | 
			
		||||
{
 | 
			
		||||
  out_data_decide_throttle(0);  // Initialize throttle decider.
 | 
			
		||||
  out_data_ring(NULL, 0);       // Initialize output ring-buffer.
 | 
			
		||||
  bool has_input = (input != NULL && input[0] != NUL);
 | 
			
		||||
  bool has_input = (input != NULL && len > 0);
 | 
			
		||||
 | 
			
		||||
  // the output buffer
 | 
			
		||||
  StringBuilder buf = KV_INITIAL_VALUE;
 | 
			
		||||
 
 | 
			
		||||
@@ -374,8 +374,8 @@ describe('system()', function()
 | 
			
		||||
    describe('with linefeed characters inside List items', function()
 | 
			
		||||
      it('converts linefeed characters to NULs', function()
 | 
			
		||||
        eq(
 | 
			
		||||
          'l1\001p2\nline2\001a\001b\nl3',
 | 
			
		||||
          eval([[system('cat -', ["l1\np2", "line2\na\nb", 'l3'])]])
 | 
			
		||||
          '\001l1\001p2\nline2\001a\001b\nl3',
 | 
			
		||||
          eval([[system('cat -', ["\nl1\np2", "line2\na\nb", 'l3'])]])
 | 
			
		||||
        )
 | 
			
		||||
      end)
 | 
			
		||||
    end)
 | 
			
		||||
@@ -496,8 +496,8 @@ describe('systemlist()', function()
 | 
			
		||||
    describe('with linefeed characters inside list items', function()
 | 
			
		||||
      it('converts linefeed characters to NULs', function()
 | 
			
		||||
        eq(
 | 
			
		||||
          { 'l1\np2', 'line2\na\nb', 'l3' },
 | 
			
		||||
          eval([[systemlist('cat -', ["l1\np2", "line2\na\nb", 'l3'])]])
 | 
			
		||||
          { '\nl1\np2', 'line2\na\nb', 'l3' },
 | 
			
		||||
          eval([[systemlist('cat -', ["\nl1\np2", "line2\na\nb", 'l3'])]])
 | 
			
		||||
        )
 | 
			
		||||
      end)
 | 
			
		||||
    end)
 | 
			
		||||
@@ -558,6 +558,12 @@ end)
 | 
			
		||||
describe('shell :!', function()
 | 
			
		||||
  before_each(clear)
 | 
			
		||||
 | 
			
		||||
  it(':{range}! works when the first char is NUL #34163', function()
 | 
			
		||||
    api.nvim_buf_set_lines(0, 0, -1, true, { '\0hello', 'hello' })
 | 
			
		||||
    command('%!cat')
 | 
			
		||||
    eq({ '\0hello', 'hello' }, api.nvim_buf_get_lines(0, 0, -1, true))
 | 
			
		||||
  end)
 | 
			
		||||
 | 
			
		||||
  it(':{range}! with powershell filter/redirect #16271 #19250', function()
 | 
			
		||||
    local screen = Screen.new(500, 8)
 | 
			
		||||
    local found = n.set_shell_powershell(true)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user