refactor: log error on invalid JSON in LSP configuration options
This commit is contained in:
parent
8aa8e5cd3d
commit
cb8e4cb988
1 changed files with 7 additions and 6 deletions
|
|
@ -2026,18 +2026,19 @@ fn send_lsp_init_request(self: *Self, lsp: *const LSP, project_path: []const u8,
|
||||||
|
|
||||||
const version = if (root.version.len > 0 and root.version[0] == 'v') root.version[1..] else root.version;
|
const version = if (root.version.len > 0 and root.version[0] == 'v') root.version[1..] else root.version;
|
||||||
const initializationOptions: struct {
|
const initializationOptions: struct {
|
||||||
pub fn cborEncode(self_: @This(), writer: *std.Io.Writer) std.io.Writer.Error!void {
|
pub fn cborEncode(ctx: @This(), writer: *std.Io.Writer) std.io.Writer.Error!void {
|
||||||
const toCbor = cbor.fromJsonAlloc(self_.alloc, self_.options) catch {
|
const toCbor = cbor.fromJsonAlloc(ctx.self.allocator, ctx.language_server_options) catch {
|
||||||
try cbor.writeValue(writer, null);
|
try cbor.writeValue(writer, null);
|
||||||
|
ctx.self.logger_lsp.print_err("init", "ignored invalid JSON in LSP initialization options", .{});
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
defer self_.alloc.free(toCbor);
|
defer ctx.self.allocator.free(toCbor);
|
||||||
|
|
||||||
writer.writeAll(toCbor) catch return error.WriteFailed;
|
writer.writeAll(toCbor) catch return error.WriteFailed;
|
||||||
}
|
}
|
||||||
options: []const u8,
|
self: *Self,
|
||||||
alloc: std.mem.Allocator,
|
language_server_options: []const u8,
|
||||||
} = .{ .options = language_server_options, .alloc = self.allocator };
|
} = .{ .self = self, .language_server_options = language_server_options };
|
||||||
|
|
||||||
try lsp.send_request(self.allocator, "initialize", .{
|
try lsp.send_request(self.allocator, "initialize", .{
|
||||||
.initializationOptions = initializationOptions,
|
.initializationOptions = initializationOptions,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue