ignore an unknown CodeActionKind (#1001)
This commit is contained in:
parent
0f77fd5b0e
commit
36738501cf
14
src/lsp.zig
14
src/lsp.zig
@ -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;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user