fix: don't use extract_cbor on language_server_options
Also, simplify cbor encoding of initializationOptions.
This commit is contained in:
parent
8890ec7497
commit
19b38609f8
2 changed files with 10 additions and 16 deletions
|
|
@ -2025,28 +2025,22 @@ 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 Options = struct {
|
||||
pub fn cborEncode(options: @This(), writer: *std.Io.Writer) std.io.Writer.Error!void {
|
||||
const msg = std.mem.replaceOwned(u8, options.alloc, options.option, "\\\"", "\"") catch {
|
||||
try cbor.writeValue(writer, "");
|
||||
const initializationOptions: struct {
|
||||
pub fn cborEncode(self_: @This(), writer: *std.Io.Writer) std.io.Writer.Error!void {
|
||||
const toCbor = cbor.fromJsonAlloc(self_.alloc, self_.options) catch {
|
||||
try cbor.writeValue(writer, cbor.null_);
|
||||
return;
|
||||
};
|
||||
defer options.alloc.free(msg);
|
||||
|
||||
const toCbor = cbor.fromJsonAlloc(options.alloc, msg[1..]) catch {
|
||||
try cbor.writeValue(writer, "");
|
||||
return;
|
||||
};
|
||||
defer options.alloc.free(toCbor);
|
||||
defer self_.alloc.free(toCbor);
|
||||
|
||||
writer.writeAll(toCbor) catch return error.WriteFailed;
|
||||
}
|
||||
option: []const u8,
|
||||
options: []const u8,
|
||||
alloc: std.mem.Allocator,
|
||||
};
|
||||
const initOptions: Options = .{ .option = language_server_options, .alloc = self.allocator };
|
||||
} = .{ .options = language_server_options, .alloc = self.allocator };
|
||||
|
||||
try lsp.send_request(self.allocator, "initialize", .{
|
||||
.initializationOptions = initOptions,
|
||||
.initializationOptions = initializationOptions,
|
||||
.processId = if (builtin.os.tag == .linux) std.os.linux.getpid() else null,
|
||||
.rootPath = project_path,
|
||||
.rootUri = project_uri,
|
||||
|
|
|
|||
|
|
@ -448,7 +448,7 @@ const Process = struct {
|
|||
self.add_task(project_directory, task) catch |e| return from.forward_error(e, @errorReturnTrace()) catch error.ClientFailed;
|
||||
} else if (try cbor.match(m.buf, .{ "delete_task", tp.extract(&project_directory), tp.extract(&task) })) {
|
||||
self.delete_task(project_directory, task) catch |e| return from.forward_error(e, @errorReturnTrace()) catch error.ClientFailed;
|
||||
} else if (try cbor.match(m.buf, .{ "did_open", tp.extract(&project_directory), tp.extract(&path), tp.extract(&file_type), tp.extract_cbor(&language_server), tp.extract_cbor(&language_server_options), tp.extract(&version), tp.extract(&text_ptr), tp.extract(&text_len) })) {
|
||||
} else if (try cbor.match(m.buf, .{ "did_open", tp.extract(&project_directory), tp.extract(&path), tp.extract(&file_type), tp.extract_cbor(&language_server), tp.extract(&language_server_options), tp.extract(&version), tp.extract(&text_ptr), tp.extract(&text_len) })) {
|
||||
const text = if (text_len > 0) @as([*]const u8, @ptrFromInt(text_ptr))[0..text_len] else "";
|
||||
self.did_open(project_directory, path, file_type, language_server, language_server_options, version, text) catch |e| return from.forward_error(e, @errorReturnTrace()) catch error.ClientFailed;
|
||||
} else if (try cbor.match(m.buf, .{ "did_change", tp.extract(&project_directory), tp.extract(&path), tp.extract(&version), tp.extract(&text_dst_ptr), tp.extract(&text_dst_len), tp.extract(&text_src_ptr), tp.extract(&text_src_len), tp.extract(&eol_mode) })) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue