From f73537733968b4bd22e72a200919fc7c7f1c3a0f Mon Sep 17 00:00:00 2001 From: Civitasv Date: Fri, 1 Dec 2023 11:12:16 +0800 Subject: [PATCH] fix: when there is no buildPresets field, it should not popup error --- lua/cmake-tools/presets.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lua/cmake-tools/presets.lua b/lua/cmake-tools/presets.lua index a7df71be..98f1dfb8 100644 --- a/lua/cmake-tools/presets.lua +++ b/lua/cmake-tools/presets.lua @@ -117,9 +117,11 @@ function presets.parse(type, opts, cwd) if not data then error("Error when parsing the presets file") end - for _, v in pairs(data[type]) do - if include_hidden or not v["hidden"] then - table.insert(options, v["name"]) + if data[type] then + for _, v in pairs(data[type]) do + if include_hidden or not v["hidden"] then + table.insert(options, v["name"]) + end end end return options