diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2026-04-26 09:55:52 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-26 09:55:52 -0400 |
| commit | 6d0cdcd605cda4041f7d924e11eebe6039769bc1 (patch) | |
| tree | 6309f03195d794d055d2732b3e1346fa97e57d02 /test/functional/vimscript | |
| parent | 682067c46a7e053270fceb3e498aea4083d4d9c9 (diff) | |
| download | rneovim-6d0cdcd605cda4041f7d924e11eebe6039769bc1.tar.gz rneovim-6d0cdcd605cda4041f7d924e11eebe6039769bc1.tar.bz2 rneovim-6d0cdcd605cda4041f7d924e11eebe6039769bc1.zip | |
fix(eval): writestring() handling of null #39328
Problem:
- write_blob, write_string dereference args which may be NULL.
- `writefile(v:_null_blob, …)` fails.
Solution:
- Fix the annotation.
- Handle null blob.
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Diffstat (limited to 'test/functional/vimscript')
| -rw-r--r-- | test/functional/vimscript/writefile_spec.lua | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/test/functional/vimscript/writefile_spec.lua b/test/functional/vimscript/writefile_spec.lua index f406e5a469..b784868a7b 100644 --- a/test/functional/vimscript/writefile_spec.lua +++ b/test/functional/vimscript/writefile_spec.lua @@ -65,6 +65,13 @@ describe('writefile()', function() eq('\n', read_file(fname)) end) + it('writes a null blob to a file', function() + eq(0, fn.writefile({ 'line1' }, fname, 'b')) + eq('line1', read_file(fname)) + command(('call writefile(v:_null_blob, "%s")'):format(fname)) + eq('', read_file(fname)) + end) + it('appends to a file', function() eq(nil, read_file(fname)) eq(0, fn.writefile({ 'abc', 'def', 'ghi' }, fname)) @@ -100,7 +107,7 @@ describe('writefile()', function() eq('a\0', read_file(fname)) end) - it('writes Lua strings to a file', function() + it('writes Lua (binary) strings to a file', function() eq(0, exec_lua([[return vim.fn.writefile('foo\0bar', ..., 'b')]], fname)) eq('foo\0bar', read_file(fname)) end) |