From 71500428b6f653133d634f407c1ae55d50788288 Mon Sep 17 00:00:00 2001 From: Alexandros Naskos Date: Sun, 7 Jun 2020 12:20:41 +0300 Subject: [PATCH] Fixed occasional crash --- src/analysis.zig | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/analysis.zig b/src/analysis.zig index 5541041..20887fb 100644 --- a/src/analysis.zig +++ b/src/analysis.zig @@ -1221,12 +1221,17 @@ fn getDocumentSymbolsInternal(allocator: *std.mem.Allocator, tree: *ast.Tree, no std.debug.warn("NULL NAME: {}\n", .{node.id}); } + const maybe_name = if (getDeclName(tree, node)) |name| + name + else + ""; + // TODO: Get my lazy bum to fix detail newlines return types.DocumentSymbol{ - .name = if ((getDeclName(tree, node) orelse "no_name").len == 0) switch (node.id) { + .name = if (maybe_name.len == 0) switch (node.id) { .TestDecl => "Nameless Test", - else => "no_name" - } else getDeclName(tree, node).?, + else => "no_name", + } else maybe_name, // .detail = (try getDocComments(allocator, tree, node)) orelse "", .detail = "", .kind = switch (node.id) {