From 769fecf9c8af6b3de2fc5f535d71db21068a988c Mon Sep 17 00:00:00 2001 From: Tw Date: Tue, 16 Nov 2021 16:01:23 +0800 Subject: [PATCH] only send format editings when necessary If the original document is same as the formatted one, there's no need to send the unchanged document's content back which will make the client confused. Signed-off-by: Tw --- src/main.zig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.zig b/src/main.zig index 8459099..4a66ad8 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1650,6 +1650,8 @@ fn formattingHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: switch (try process.wait()) { .Exited => |code| if (code == 0) { + if (std.mem.eql(u8, handle.document.text, stdout_bytes)) return try respondGeneric(id, null_result_response); + return try send(arena, types.Response{ .id = id, .result = .{