Skip to content

Commit

Permalink
fix: when there is no buildPresets field, it should not popup error
Browse files Browse the repository at this point in the history
  • Loading branch information
Civitasv committed Dec 1, 2023
1 parent 8474524 commit edbf419
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions lua/cmake-tools/presets.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -141,9 +143,11 @@ function presets.parse_name_mapped(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
options[v["name"]] = v
if data[type] then
for _, v in pairs(data[type]) do
if include_hidden or not v["hidden"] then
options[v["name"]] = v
end
end
end
return options
Expand All @@ -158,9 +162,11 @@ function presets.get_preset_by_name(name, type, cwd)
return nil
end
local data = decode(file)
for _, v in pairs(data[type]) do
if v.name == name then
return v
if data[type] then
for _, v in pairs(data[type]) do
if v.name == name then
return v
end
end
end
return nil
Expand Down

0 comments on commit edbf419

Please sign in to comment.