From 1ed8d49b305a4ed03578eb251b18e5bd193ec04c Mon Sep 17 00:00:00 2001 From: Techatrix <19954306+Techatrix@users.noreply.github.com> Date: Sat, 21 Jan 2023 01:33:27 +0100 Subject: [PATCH] fix builtin completions if `label_details_support` is false (#924) --- src/Server.zig | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Server.zig b/src/Server.zig index e3bef95..d5ece4e 100644 --- a/src/Server.zig +++ b/src/Server.zig @@ -1326,16 +1326,15 @@ fn completeBuiltin(server: *Server) error{OutOfMemory}!?[]types.CompletionItem { }); } - var completions = try allocator.alloc(types.CompletionItem, builtin_completions.items.len); + var completions = try builtin_completions.clone(allocator); if (server.client_capabilities.label_details_support) { - for (builtin_completions.items) |item, i| { - completions[i] = item; - try formatDetailledLabel(&completions[i], allocator); + for (completions.items) |*item| { + try formatDetailledLabel(item, allocator); } } - return completions; + return completions.items; } fn completeGlobal(server: *Server, pos_index: usize, handle: *const DocumentStore.Handle) error{OutOfMemory}![]types.CompletionItem {