From 8649818fb29322a8ee24c5cd2cd7b2f6c40258a3 Mon Sep 17 00:00:00 2001 From: Luis Calle <53507599+TheLeoP@users.noreply.github.com> Date: Wed, 19 Mar 2025 17:10:58 -0500 Subject: [PATCH] fix(trash-win): don't hang when `shellslash` is enabled (#592) --- .../adapters/trash/windows/powershell-connection.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lua/oil/adapters/trash/windows/powershell-connection.lua b/lua/oil/adapters/trash/windows/powershell-connection.lua index a296a7e..332defb 100644 --- a/lua/oil/adapters/trash/windows/powershell-connection.lua +++ b/lua/oil/adapters/trash/windows/powershell-connection.lua @@ -28,6 +28,16 @@ end ---@param init_command? string function PowershellConnection:_init(init_command) + -- For some reason beyond my understanding, at least one of the following + -- things requires `noshellslash` to avoid the embeded powershell process to + -- send only "" to the stdout (never calling the callback because + -- "===DONE(True)===" is never sent to stdout) + -- * vim.fn.jobstart + -- * cmd.exe + -- * powershell.exe + local saved_shellslash = vim.o.shellslash + vim.o.shellslash = false + -- 65001 is the UTF-8 codepage -- powershell needs to be launched with the UTF-8 codepage to use it for both stdin and stdout local jid = vim.fn.jobstart({ @@ -57,6 +67,7 @@ function PowershellConnection:_init(init_command) end end, }) + vim.o.shellslash = saved_shellslash if jid == 0 then self:_set_error("passed invalid arguments to 'powershell'")