Fixed occasional crash

This commit is contained in:
Alexandros Naskos 2020-06-07 12:20:41 +03:00
parent d35a71806b
commit 71500428b6

View File

@ -1221,12 +1221,17 @@ fn getDocumentSymbolsInternal(allocator: *std.mem.Allocator, tree: *ast.Tree, no
std.debug.warn("NULL NAME: {}\n", .{node.id}); 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 // TODO: Get my lazy bum to fix detail newlines
return types.DocumentSymbol{ 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", .TestDecl => "Nameless Test",
else => "no_name" else => "no_name",
} else getDeclName(tree, node).?, } else maybe_name,
// .detail = (try getDocComments(allocator, tree, node)) orelse "", // .detail = (try getDocComments(allocator, tree, node)) orelse "",
.detail = "", .detail = "",
.kind = switch (node.id) { .kind = switch (node.id) {