From e58bddd769660f479744a32e4a32ddbaa1c782cf Mon Sep 17 00:00:00 2001 From: Nick Cernis Date: Thu, 10 Nov 2022 05:13:35 +0100 Subject: [PATCH] Improve Zig version mismatch error (#744) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Improves the server message we send if the system Zig version is older than the Zig version that ZLS was built with: - Correct typo (“build with” → “built with”). - Show versions so users know which one they need to update to. - Suggest step needed to fix the error (“Update Zig…”). --- src/Server.zig | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Server.zig b/src/Server.zig index 1cb2f68..6cea29c 100644 --- a/src/Server.zig +++ b/src/Server.zig @@ -1634,10 +1634,8 @@ fn initializeHandler(server: *Server, writer: anytype, id: types.RequestId, req: const zig_exe_version = std.SemanticVersion.parse(env.version) catch return; if (zig_builtin.zig_version.order(zig_exe_version) == .gt) { - try server.showMessage(writer, .Warning, - \\ZLS has been build with a newer version than you are using! - \\This may cause unexpected issues. - ); + const version_mismatch_message = try std.fmt.allocPrint(server.arena.allocator(), "ZLS was built with Zig {}, but your Zig version is {s}. Update Zig to avoid unexpected behavior.", .{ zig_builtin.zig_version, env.version }); + try server.showMessage(writer, .Warning, version_mismatch_message); } }