Skip to content

Commit b5c2200

Browse files
committed
remove workaround for number literal hover with Zed editor
1 parent 7fc54f3 commit b5c2200

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

src/Server.zig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1799,7 +1799,6 @@ fn hoverHandler(server: *Server, arena: std.mem.Allocator, request: types.HoverP
17991799
source_index,
18001800
markup_kind,
18011801
server.offset_encoding,
1802-
server.client_capabilities.client_name,
18031802
);
18041803
}
18051804

src/features/hover.zig

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,6 @@ fn hoverNumberLiteral(
354354
token_index: Ast.TokenIndex,
355355
arena: std.mem.Allocator,
356356
markup_kind: types.MarkupKind,
357-
client_name: ?[]const u8,
358357
) error{OutOfMemory}!?[]const u8 {
359358
const tree = handle.tree;
360359
// number literals get tokenized separately from their minus sign
@@ -373,19 +372,15 @@ fn hoverNumberLiteral(
373372
}
374373
};
375374

376-
// Zed currently doesn't render markdown unless wrapped in code blocks
377-
// Remove this when this issue is closed https://github.com/zed-industries/zed/issues/5386
378-
const is_zed = if (client_name) |name| std.mem.startsWith(u8, name, "Zed") else false;
379375
switch (markup_kind) {
380376
.markdown => return try std.fmt.allocPrint(arena,
381-
\\{[md_ticks]s}| Base | {[value]s:<[count]} |
377+
\\| Base | {[value]s:<[count]} |
382378
\\| ---- | {[dash]s:-<[count]} |
383379
\\| BIN | {[sign]s}0b{[number]b:<[len]} |
384380
\\| OCT | {[sign]s}0o{[number]o:<[len]} |
385381
\\| DEC | {[sign]s}{[number]d:<[len]} |
386-
\\| HEX | {[sign]s}0x{[number]X:<[len]} |{[md_ticks]s}
382+
\\| HEX | {[sign]s}0x{[number]X:<[len]} |
387383
, .{
388-
.md_ticks = if (is_zed) "\n```" else "",
389384
.sign = if (is_negative) "-" else "",
390385
.dash = "-",
391386
.value = "Value",
@@ -411,15 +406,14 @@ fn hoverDefinitionNumberLiteral(
411406
source_index: usize,
412407
markup_kind: types.MarkupKind,
413408
offset_encoding: offsets.Encoding,
414-
client_name: ?[]const u8,
415409
) !?types.Hover {
416410
const tracy_zone = tracy.trace(@src());
417411
defer tracy_zone.end();
418412

419413
const tree = handle.tree;
420414
const token_index = offsets.sourceIndexToTokenIndex(tree, source_index).pickPreferred(&.{ .number_literal, .char_literal }, &tree) orelse return null;
421415
const num_loc = offsets.tokenToLoc(tree, token_index);
422-
const hover_text = (try hoverNumberLiteral(handle, token_index, arena, markup_kind, client_name)) orelse return null;
416+
const hover_text = (try hoverNumberLiteral(handle, token_index, arena, markup_kind)) orelse return null;
423417

424418
return .{
425419
.contents = .{ .MarkupContent = .{
@@ -437,7 +431,6 @@ pub fn hover(
437431
source_index: usize,
438432
markup_kind: types.MarkupKind,
439433
offset_encoding: offsets.Encoding,
440-
client_name: ?[]const u8,
441434
) !?types.Hover {
442435
const pos_context = try Analyser.getPositionContext(arena, handle.tree, source_index, true);
443436

@@ -447,7 +440,7 @@ pub fn hover(
447440
.field_access => |loc| try hoverDefinitionFieldAccess(analyser, arena, handle, source_index, loc, markup_kind, offset_encoding),
448441
.label_access, .label_decl => |loc| try hoverDefinitionLabel(analyser, arena, handle, source_index, loc, markup_kind, offset_encoding),
449442
.enum_literal => try hoverDefinitionEnumLiteral(analyser, arena, handle, source_index, markup_kind, offset_encoding),
450-
.number_literal, .char_literal => try hoverDefinitionNumberLiteral(arena, handle, source_index, markup_kind, offset_encoding, client_name),
443+
.number_literal, .char_literal => try hoverDefinitionNumberLiteral(arena, handle, source_index, markup_kind, offset_encoding),
451444
else => null,
452445
};
453446

0 commit comments

Comments
 (0)