ignore an unknown CodeActionKind (#1001)

This commit is contained in:
Techatrix 2023-02-21 22:27:47 +00:00 committed by GitHub
parent 0f77fd5b0e
commit 36738501cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -712,7 +712,7 @@ pub const CodeActionKind = enum {
// Some clients (nvim) may report these by the enumeration names rather than the // Some clients (nvim) may report these by the enumeration names rather than the
// actual strings, so let's check those names here // actual strings, so let's check those names here
const aliases = [_]struct { []const u8, CodeActionKind }{ const aliases = std.ComptimeStringMap(CodeActionKind, .{
.{ "Empty", .empty }, .{ "Empty", .empty },
.{ "QuickFix", .quickfix }, .{ "QuickFix", .quickfix },
.{ "Refactor", .refactor }, .{ "Refactor", .refactor },
@ -722,15 +722,15 @@ pub const CodeActionKind = enum {
.{ "Source", .source }, .{ "Source", .source },
.{ "SourceOrganizeImports", .@"source.organizeImports" }, .{ "SourceOrganizeImports", .@"source.organizeImports" },
.{ "SourceFixAll", .@"source.fixAll" }, .{ "SourceFixAll", .@"source.fixAll" },
}; });
for (aliases) |alias| { if (aliases.get(json_value.String)) |alias| {
if (std.mem.eql(u8, json_value.String, alias[0])) { return alias;
return alias[1];
}
} }
return error.InvalidEnumTag; // Strictly speaking, CodeActionKind is a string an not a enum which means that
// a client may report a unknown kind which can safely be ignored
return .empty;
} }
}; };