add colon to inlay hint label (#944)

This commit is contained in:
Techatrix 2023-01-27 15:59:11 +01:00 committed by GitHub
parent e055f9d15c
commit 2857237f74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -55,7 +55,7 @@ const Builder = struct {
try self.hints.append(self.arena, .{
.position = position,
.label = .{ .string = label },
.label = .{ .string = try std.fmt.allocPrint(self.arena, "{s}:", .{label}) },
.kind = types.InlayHintKind.Parameter,
.tooltip = .{ .MarkupContent = .{
.kind = self.hover_kind,

View File

@ -120,7 +120,10 @@ fn testInlayHints(source: []const u8) !void {
for (hints) |hint| {
if (position.line != hint.position.line or position.character != hint.position.character) continue;
const actual_label = hint.label[0..hint.label.len];
if(!std.mem.endsWith(u8, hint.label, ":")) {
try error_builder.msgAtLoc("label `{s}` must end with a colon!", new_loc, .err, .{ hint.label });
}
const actual_label = hint.label[0..hint.label.len - 1];
if (!std.mem.eql(u8, expected_label, actual_label)) {
try error_builder.msgAtLoc("expected label `{s}` here but got `{s}`!", new_loc, .err, .{ expected_label, actual_label });