From 1b5892fe124df0c9a2acd680301f70eaf87c984b Mon Sep 17 00:00:00 2001 From: RedH <114261766+thisRedH@users.noreply.github.com> Date: Sun, 22 Dec 2024 03:59:18 +0100 Subject: [PATCH] fix: replace backslashes on Windows for pattern (#273) Co-authored-by: thisRedH --- lua/cmake-tools/init.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lua/cmake-tools/init.lua b/lua/cmake-tools/init.lua index 531648a..a488a09 100644 --- a/lua/cmake-tools/init.lua +++ b/lua/cmake-tools/init.lua @@ -1401,6 +1401,11 @@ function cmake.create_regenerate_on_save_autocmd() table.insert(pattern, ss) end + local cwd = config.cwd + if require("cmake-tools.osys").iswin32 then + cwd = config.cwd:gsub("\\", "/") + end + local presets_exists = config.base_settings.use_preset and Presets.exists(config.cwd) if presets_exists then for _, item in ipairs({ @@ -1409,7 +1414,7 @@ function cmake.create_regenerate_on_save_autocmd() "cmake-presets.json", "cmake-user-presets.json", }) do - table.insert(pattern, config.cwd .. "/" .. item) + table.insert(pattern, cwd .. "/" .. item) end else for _, item in ipairs({ @@ -1420,7 +1425,7 @@ function cmake.create_regenerate_on_save_autocmd() "CMakeKits.json", "cmake-kits.json", }) do - table.insert(pattern, config.cwd .. "/" .. item) + table.insert(pattern, cwd .. "/" .. item) end end