Skip to content

Commit

Permalink
only send format editings when necessary
Browse files Browse the repository at this point in the history
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 <tw19881113@gmail.com>
  • Loading branch information
tw4452852 committed Jun 7, 2022
1 parent 327e66c commit e5098eb
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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 = .{
Expand Down

0 comments on commit e5098eb

Please sign in to comment.