From b82db08e3889dc3d93e204f169cc09cb40c38182 Mon Sep 17 00:00:00 2001 From: pysan3 Date: Thu, 22 Feb 2024 20:11:09 +0900 Subject: [PATCH] fix(base): fix shellescape to work on Windows --- lua/pathlib/base.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/pathlib/base.lua b/lua/pathlib/base.lua index a891e7a..534fffd 100644 --- a/lua/pathlib/base.lua +++ b/lua/pathlib/base.lua @@ -1005,12 +1005,16 @@ end ---@param special boolean|nil # If true, special items such as "!", "%", "#" and "" will be preceded by a backslash. The backslash will be removed again by the `:!` command. See `:h shellescape` for more details. The character is escaped. ---@return PathlibString function Path:shell_string(special) + local quote = [["]] local s = table.concat( vim.tbl_map(function(t) - return vim.fn.shellescape(t, special) + local escape = vim.fn.shellescape(t, special) + quote = escape:sub(1, 1) + return escape:sub(2, #escape - 1) end, self._raw_paths), "/" ) + s = quote .. s .. quote if self._drive_name:len() > 0 then s = self._drive_name .. s end