mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-08-25 00:21:46 +00:00
config: refill after ignored line boundaries (#13638)
Fixes https://github.com/ghostty-org/ghostty/discussions/13441 Refill the line iterator when an ignored comment or blank line consumes the remaining buffered data. Configuration parsing previously stopped silently at these boundaries and left every subsequent setting unapplied. Request more data before continuing the loop and cover both comment and blank line boundaries with buffered-reader regression tests.
This commit is contained in:
@@ -1454,8 +1454,15 @@ pub const LineIterator = struct {
|
||||
entry = entry[0..trim.len];
|
||||
}
|
||||
|
||||
// Ignore blank lines and comments
|
||||
if (entry.len == 0 or entry[0] == '#') continue;
|
||||
// Ignore blank lines and comments. If this line consumed the
|
||||
// remaining buffer, refill before the loop condition checks for
|
||||
// more data.
|
||||
if (entry.len == 0 or entry[0] == '#') {
|
||||
if (self.r.seek == self.r.end) {
|
||||
self.r.fillMore() catch {};
|
||||
}
|
||||
continue;
|
||||
}
|
||||
break entry;
|
||||
} else return null;
|
||||
|
||||
@@ -1623,3 +1630,27 @@ test "LineIterator with buffered and primed reader" {
|
||||
try testing.expectEqual(@as(?[]const u8, null), iter.next());
|
||||
try testing.expectEqual(@as(?[]const u8, null), iter.next());
|
||||
}
|
||||
|
||||
test "LineIterator refills after ignored line at buffer boundary" {
|
||||
const testing = std.testing;
|
||||
|
||||
{
|
||||
var f: std.Io.Reader = .fixed("#\nA\n");
|
||||
var buf: [2]u8 = undefined;
|
||||
var r = f.limited(.unlimited, &buf);
|
||||
var iter: LineIterator = .init(&r.interface);
|
||||
|
||||
try testing.expectEqualStrings("--A", iter.next().?);
|
||||
try testing.expectEqual(@as(?[]const u8, null), iter.next());
|
||||
}
|
||||
|
||||
{
|
||||
var f: std.Io.Reader = .fixed("\nA\n");
|
||||
var buf: [1]u8 = undefined;
|
||||
var r = f.limited(.unlimited, &buf);
|
||||
var iter: LineIterator = .init(&r.interface);
|
||||
|
||||
try testing.expectEqualStrings("--A", iter.next().?);
|
||||
try testing.expectEqual(@as(?[]const u8, null), iter.next());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user