Skip to content

Commit

Permalink
ignore notifications methods that start with '$/'
Browse files Browse the repository at this point in the history
  • Loading branch information
Techatrix committed Jan 6, 2025
1 parent a877dee commit d830e93
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions src/Server.zig
Original file line number Diff line number Diff line change
Expand Up @@ -674,12 +674,6 @@ fn exitHandler(server: *Server, _: std.mem.Allocator, _: void) Error!void {
};
}

fn cancelRequestHandler(server: *Server, _: std.mem.Allocator, request: types.CancelParams) Error!void {
_ = server;
_ = request;
// TODO implement $/cancelRequest
}

fn registerCapability(server: *Server, method: []const u8) Error!void {
const id = try std.fmt.allocPrint(server.allocator, "register-{s}", .{method});
defer server.allocator.free(id);
Expand Down Expand Up @@ -1821,7 +1815,6 @@ const HandledRequestParams = union(enum) {
const HandledNotificationParams = union(enum) {
initialized: types.InitializedParams,
exit,
@"$/cancelRequest": types.CancelParams,
@"textDocument/didOpen": types.DidOpenTextDocumentParams,
@"textDocument/didChange": types.DidChangeTextDocumentParams,
@"textDocument/didSave": types.DidSaveTextDocumentParams,
Expand Down Expand Up @@ -1865,7 +1858,6 @@ fn isBlockingMessage(msg: Message) bool {
.other => return false,
},
.notification => |notification| switch (notification.params) {
.@"$/cancelRequest" => return false,
.initialized,
.exit,
.@"textDocument/didOpen",
Expand Down Expand Up @@ -2048,7 +2040,6 @@ pub fn sendNotificationSync(server: *Server, arena: std.mem.Allocator, comptime
return switch (@field(Params, method)) {
.initialized => try server.initializedHandler(arena, params),
.exit => try server.exitHandler(arena, params),
.@"$/cancelRequest" => try server.cancelRequestHandler(arena, params),
.@"textDocument/didOpen" => try server.openDocumentHandler(arena, params),
.@"textDocument/didChange" => try server.changeDocumentHandler(arena, params),
.@"textDocument/didSave" => try server.saveDocumentHandler(arena, params),
Expand Down Expand Up @@ -2171,6 +2162,7 @@ fn validateMessage(server: *const Server, message: Message) Error!void {

// https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#dollarRequests
if (message == .request and std.mem.startsWith(u8, method, "$/")) return error.MethodNotFound;
if (message == .notification and std.mem.startsWith(u8, method, "$/")) return;

switch (server.status) {
.uninitialized => blk: {
Expand Down

0 comments on commit d830e93

Please sign in to comment.