neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 8b9500c886bdb72620e331d430e166ad7d9c12f8
parent 06043af27d9c9258eeebf16e4691dcb92f9b857d
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Sun, 25 May 2025 09:28:11 +0800

fix(system): don't treat NUL at start as no input (#34167)


Diffstat:
Msrc/nvim/os/shell.c | 2+-
Mtest/functional/vimscript/system_spec.lua | 14++++++++++----
2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c @@ -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; diff --git a/test/functional/vimscript/system_spec.lua b/test/functional/vimscript/system_spec.lua @@ -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 using "commands" filter/redirect #16271 #19250', function() if not n.has_powershell() then return