mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
config: unicode range parser is more lenient about whitespace
This commit is contained in:
@ -1571,7 +1571,7 @@ pub const RepeatableCodepointMap = struct {
|
|||||||
/// U+1234-5678
|
/// U+1234-5678
|
||||||
/// U+1234,U+5678
|
/// U+1234,U+5678
|
||||||
/// U+1234-5678,U+5678
|
/// U+1234-5678,U+5678
|
||||||
/// U+1234,U+5678-9ABC
|
/// U+1234,U+5678-U+9ABC
|
||||||
///
|
///
|
||||||
/// etc.
|
/// etc.
|
||||||
const UnicodeRangeParser = struct {
|
const UnicodeRangeParser = struct {
|
||||||
@ -1586,12 +1586,16 @@ pub const RepeatableCodepointMap = struct {
|
|||||||
const start = try self.parseCodepoint();
|
const start = try self.parseCodepoint();
|
||||||
if (self.eof()) return .{ start, start };
|
if (self.eof()) return .{ start, start };
|
||||||
|
|
||||||
|
// We're allowed to have any whitespace here
|
||||||
|
self.consumeWhitespace();
|
||||||
|
|
||||||
// Otherwise we expect either a range or a comma
|
// Otherwise we expect either a range or a comma
|
||||||
switch (self.input[self.i]) {
|
switch (self.input[self.i]) {
|
||||||
// Comma means we have another codepoint but in a different
|
// Comma means we have another codepoint but in a different
|
||||||
// range so we return our current codepoint.
|
// range so we return our current codepoint.
|
||||||
',' => {
|
',' => {
|
||||||
self.advance();
|
self.advance();
|
||||||
|
self.consumeWhitespace();
|
||||||
if (self.eof()) return error.InvalidValue;
|
if (self.eof()) return error.InvalidValue;
|
||||||
return .{ start, start };
|
return .{ start, start };
|
||||||
},
|
},
|
||||||
@ -1599,10 +1603,14 @@ pub const RepeatableCodepointMap = struct {
|
|||||||
// Hyphen means we have a range.
|
// Hyphen means we have a range.
|
||||||
'-' => {
|
'-' => {
|
||||||
self.advance();
|
self.advance();
|
||||||
|
self.consumeWhitespace();
|
||||||
if (self.eof()) return error.InvalidValue;
|
if (self.eof()) return error.InvalidValue;
|
||||||
const end = try self.parseCodepoint();
|
const end = try self.parseCodepoint();
|
||||||
|
self.consumeWhitespace();
|
||||||
if (!self.eof() and self.input[self.i] != ',') return error.InvalidValue;
|
if (!self.eof() and self.input[self.i] != ',') return error.InvalidValue;
|
||||||
self.advance();
|
self.advance();
|
||||||
|
self.consumeWhitespace();
|
||||||
|
if (start > end) return error.InvalidValue;
|
||||||
return .{ start, end };
|
return .{ start, end };
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1610,6 +1618,15 @@ pub const RepeatableCodepointMap = struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn consumeWhitespace(self: *UnicodeRangeParser) void {
|
||||||
|
while (!self.eof()) {
|
||||||
|
switch (self.input[self.i]) {
|
||||||
|
' ', '\t' => self.advance(),
|
||||||
|
else => return,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn parseCodepoint(self: *UnicodeRangeParser) !u21 {
|
fn parseCodepoint(self: *UnicodeRangeParser) !u21 {
|
||||||
if (self.input[self.i] != 'U') return error.InvalidValue;
|
if (self.input[self.i] != 'U') return error.InvalidValue;
|
||||||
self.advance();
|
self.advance();
|
||||||
|
Reference in New Issue
Block a user