diff --git a/lua/cmake-tools/config.lua b/lua/cmake-tools/config.lua index 83d6043c..df6aa1ac 100644 --- a/lua/cmake-tools/config.lua +++ b/lua/cmake-tools/config.lua @@ -56,6 +56,8 @@ function Config:has_build_directory() return self.build_directory and self.build_directory:exists() end +---comment +---The reason for storing no expand build directory is to make cwd selecting easier function Config:no_expand_build_directory_path() return self.base_settings.build_dir end diff --git a/lua/cmake-tools/init.lua b/lua/cmake-tools/init.lua index f70221d2..3151edce 100644 --- a/lua/cmake-tools/init.lua +++ b/lua/cmake-tools/init.lua @@ -95,12 +95,12 @@ function cmake.generate(opt, callback) if presets_file and config.configure_preset then -- if exsist preset file and set configure preset, then -- set build directory to the `binaryDir` option of `configurePresets` - local build_directory = presets.get_build_dir( + local build_directory, no_expand_build_directory = presets.get_build_dir( presets.get_preset_by_name(config.configure_preset, "configurePresets", config.cwd), config.cwd ) if build_directory ~= "" then - config:update_build_dir(build_directory, build_directory) + config:update_build_dir(build_directory, no_expand_build_directory) end config:generate_build_directory() diff --git a/lua/cmake-tools/presets.lua b/lua/cmake-tools/presets.lua index f8e1973f..6028c7af 100644 --- a/lua/cmake-tools/presets.lua +++ b/lua/cmake-tools/presets.lua @@ -226,6 +226,7 @@ function presets.get_build_dir(preset, cwd) end local build_dir = helper(preset) + local no_expand_build_dir = build_dir -- macro expansion local source_path = Path:new(cwd) @@ -245,7 +246,7 @@ function presets.get_build_dir(preset, cwd) build_dir = vim.fn.fnamemodify(build_dir, ":.") - return build_dir + return build_dir, no_expand_build_dir end return presets