@@ -370,6 +370,7 @@ fn hoverNumberLiteral(
370370 token_index : Ast.TokenIndex ,
371371 arena : std.mem.Allocator ,
372372 markup_kind : types.MarkupKind ,
373+ client_name : ? []const u8 ,
373374) error {OutOfMemory }! ? []const u8 {
374375 const tree = handle .tree ;
375376 // number literals get tokenized separately from their minus sign
@@ -388,15 +389,19 @@ fn hoverNumberLiteral(
388389 }
389390 };
390391
392+ // Zed currently doesn't render markdown unless wrapped in code blocks
393+ // Remove this when this issue is closed https://github.com/zed-industries/zed/issues/5386
394+ const is_zed = if (client_name ) | name | std .mem .startsWith (u8 , name , "Zed" ) else false ;
391395 switch (markup_kind ) {
392396 .markdown = > return try std .fmt .allocPrint (arena ,
393- \\| Base | {[value]s:<[count]} |
397+ \\{[md_ticks]s} | Base | {[value]s:<[count]} |
394398 \\| ---- | {[dash]s:-<[count]} |
395399 \\| BIN | {[sign]s}0b{[number]b:<[len]} |
396400 \\| OCT | {[sign]s}0o{[number]o:<[len]} |
397401 \\| DEC | {[sign]s}{[number]d:<[len]} |
398- \\| HEX | {[sign]s}0x{[number]X:<[len]} |
402+ \\| HEX | {[sign]s}0x{[number]X:<[len]} |{[md_ticks]s}
399403 , .{
404+ .md_ticks = if (is_zed ) "```" else "" ,
400405 .sign = if (is_negative ) "-" else "" ,
401406 .dash = "-" ,
402407 .value = "Value" ,
@@ -422,14 +427,15 @@ fn hoverDefinitionNumberLiteral(
422427 source_index : usize ,
423428 markup_kind : types.MarkupKind ,
424429 offset_encoding : offsets.Encoding ,
430+ client_name : ? []const u8 ,
425431) ! ? types.Hover {
426432 const tracy_zone = tracy .trace (@src ());
427433 defer tracy_zone .end ();
428434
429435 const tree = handle .tree ;
430436 const token_index = offsets .sourceIndexToTokenIndex (tree , source_index );
431437 const num_loc = offsets .tokenToLoc (tree , token_index );
432- const hover_text = (try hoverNumberLiteral (handle , token_index , arena , markup_kind )) orelse return null ;
438+ const hover_text = (try hoverNumberLiteral (handle , token_index , arena , markup_kind , client_name )) orelse return null ;
433439
434440 return .{
435441 .contents = .{ .MarkupContent = .{
@@ -447,6 +453,7 @@ pub fn hover(
447453 source_index : usize ,
448454 markup_kind : types.MarkupKind ,
449455 offset_encoding : offsets.Encoding ,
456+ client_name : ? []const u8 ,
450457) ! ? types.Hover {
451458 const pos_context = try Analyser .getPositionContext (arena , handle .tree , source_index , true );
452459
@@ -456,7 +463,7 @@ pub fn hover(
456463 .field_access = > | loc | try hoverDefinitionFieldAccess (analyser , arena , handle , source_index , loc , markup_kind , offset_encoding ),
457464 .label_access , .label_decl = > | loc | try hoverDefinitionLabel (analyser , arena , handle , source_index , loc , markup_kind , offset_encoding ),
458465 .enum_literal = > try hoverDefinitionEnumLiteral (analyser , arena , handle , source_index , markup_kind , offset_encoding ),
459- .number_literal , .char_literal = > try hoverDefinitionNumberLiteral (arena , handle , source_index , markup_kind , offset_encoding ),
466+ .number_literal , .char_literal = > try hoverDefinitionNumberLiteral (arena , handle , source_index , markup_kind , offset_encoding , client_name ),
460467 else = > null ,
461468 };
462469
0 commit comments