mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-12-31 18:52:12 +00:00
config: richer diagnostics for errors
Rather than storing a list of errors we now store a list of "diagnostics." Each diagnostic has a richer set of structured information, including a message, a key, the location where it occurred. This lets us show more detailed messages, more human friendly messages, and also let's us filter by key or location. We don't take advantage of all of this capability in this initial commit, but we do use every field for something.
This commit is contained in:
@@ -112,14 +112,15 @@ fn config_trigger_(
|
||||
return trigger.cval();
|
||||
}
|
||||
|
||||
export fn ghostty_config_errors_count(self: *Config) u32 {
|
||||
return @intCast(self._errors.list.items.len);
|
||||
export fn ghostty_config_diagnostics_count(self: *Config) u32 {
|
||||
return @intCast(self._diagnostics.items().len);
|
||||
}
|
||||
|
||||
export fn ghostty_config_get_error(self: *Config, idx: u32) Error {
|
||||
if (idx >= self._errors.list.items.len) return .{};
|
||||
const err = self._errors.list.items[idx];
|
||||
return .{ .message = err.message.ptr };
|
||||
export fn ghostty_config_get_diagnostic(self: *Config, idx: u32) Diagnostic {
|
||||
const items = self._diagnostics.items();
|
||||
if (idx >= items.len) return .{};
|
||||
const message = self._diagnostics.precompute.messages.items[idx];
|
||||
return .{ .message = message.ptr };
|
||||
}
|
||||
|
||||
export fn ghostty_config_open() void {
|
||||
@@ -128,7 +129,7 @@ export fn ghostty_config_open() void {
|
||||
};
|
||||
}
|
||||
|
||||
/// Sync with ghostty_error_s
|
||||
const Error = extern struct {
|
||||
/// Sync with ghostty_diagnostic_s
|
||||
const Diagnostic = extern struct {
|
||||
message: [*:0]const u8 = "",
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user