diff options
author | Enan Ajmain <3nan.ajmain@gmail.com> | 2023-01-12 23:25:29 +0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-12 09:25:29 -0800 |
commit | 2f1fd15554921dc2375c2ad136e727229e72348a (patch) | |
tree | 2f2ed29114b03e54395a8ac84b650c8c997abd00 /test/functional/vimscript/system_spec.lua | |
parent | 572cd8031dd7c91ac9e17cbdfab16d87f1fed6b7 (diff) | |
download | rneovim-2f1fd15554921dc2375c2ad136e727229e72348a.tar.gz rneovim-2f1fd15554921dc2375c2ad136e727229e72348a.tar.bz2 rneovim-2f1fd15554921dc2375c2ad136e727229e72348a.zip |
fix(powershell): wrong length allocation for ":%w !" #20530
Problem:
The calculation of `len` in `make_filter_cmd` for powershell falls short
by one character for the following ex command:
:%w !sort
This command satisfies these conditions:
- `itmp` is not null
- `otmp` is null
__NOTE__ that other shells circumvent this bug only because of `len`
allocation for six extra characters: a pair of curly braces and four
spaces:
https://github.com/neovim/neovim/blob/cfdb4cbada8c65aa57e69776bcc0f7b8b298317a/src/nvim/ex_cmds.c#L1551-L1554
If allocation for these six characters are removed, then bash also faces
the same bug.
Solution:
Add allocation for 6 extra bytes. 1 would do, but let's keep powershell
in sync with other shells as much as possible.
Diffstat (limited to 'test/functional/vimscript/system_spec.lua')
-rw-r--r-- | test/functional/vimscript/system_spec.lua | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/functional/vimscript/system_spec.lua b/test/functional/vimscript/system_spec.lua index f099b4a36e..7ada1c4bea 100644 --- a/test/functional/vimscript/system_spec.lua +++ b/test/functional/vimscript/system_spec.lua @@ -662,4 +662,33 @@ describe('shell :!', function() 1]]) end end) + + it(':{range}! without redirecting to buffer', function() + local screen = Screen.new(500, 10) + screen:attach() + insert([[ + 3 + 1 + 4 + 2]]) + feed(':4verbose %w !sort<cr>') + if is_os('win') then + screen:expect{ + any=[[Executing command: .?sort %< .*]] + } + else + screen:expect{ + any=[[Executing command: .?%(sort%) %< .*]] + + } + end + feed('<CR>') + helpers.set_shell_powershell(true) + feed(':4verbose %w !sort<cr>') + screen:expect{ + any=[[Executing command: .?& { Get%-Content .* | & sort }]] + } + feed('<CR>') + helpers.expect_exit(command, 'qall!') + end) end) |