config: fix regression for recursive config-files from 5ff0841ee65

This commit is contained in:
Mitchell Hashimoto
2024-09-17 16:50:59 -07:00
parent b7ac7bf336
commit 0ac29783b9

View File

@ -2262,7 +2262,12 @@ pub fn loadRecursiveFiles(self: *Config, alloc_gpa: Allocator) !void {
defer loaded.deinit(); defer loaded.deinit();
const cwd = std.fs.cwd(); const cwd = std.fs.cwd();
for (0..self.@"config-file".value.list.items.len) |i| {
// We must use a while below and not a for(items) because we
// may add items to the list while iterating for recursive
// config-file entries.
var i: usize = 0;
while (i < self.@"config-file".value.list.items.len) : (i += 1) {
const optional, const path = blk: { const optional, const path = blk: {
const path = self.@"config-file".value.list.items[i]; const path = self.@"config-file".value.list.items[i];
if (path.len == 0) { if (path.len == 0) {