fix: make_filter_cmd for :! powershell #15913

Problem:
Nvim fails to create tempfile "…/nvim6UJx04/7" when 'shell' is set to
pwsh (PowerShell Core). This breaks filtered shell commands ":{range}!".
With shell set to cmd, it works.

Solution:
PowerShell doesn't use "<" for stdin redirection. Instead, use
"-RedirectStandardInput".

Closes #15913
This commit is contained in:
Enan Ajmain
2021-11-09 20:22:21 +06:00
committed by Christian Clason
parent 790f6089e9
commit 175892fa37
4 changed files with 58 additions and 10 deletions

View File

@@ -6,6 +6,8 @@ local eq, call, clear, eval, feed_command, feed, nvim =
helpers.eq, helpers.call, helpers.clear, helpers.eval, helpers.feed_command,
helpers.feed, helpers.nvim
local command = helpers.command
local insert = helpers.insert
local expect = helpers.expect
local exc_exec = helpers.exc_exec
local iswin = helpers.iswin
local os_kill = helpers.os_kill
@@ -630,3 +632,29 @@ describe('systemlist()', function()
end)
end)
it(':{range}! works with powershell for filter and redirection #16271', function()
clear()
if not helpers.has_powershell() then
pending("not tested; powershell was not found", function() end)
return
end
local screen = Screen.new(500, 8)
screen:attach()
helpers.set_shell_powershell()
insert([[
3
1
4
2]])
feed(':4verbose %!sort<cr>')
screen:expect{
any=[[Executing command: "Start%-Process sort %-RedirectStandardInput .* %-RedirectStandardOutput .* %-NoNewWindow %-Wait".*4 lines filtered.*Press ENTER or type command to continue]]
}
feed('<CR>')
expect([[
1
2
3
4]])
end)