Skip to content

Commit 4ea4847

Browse files
committed
upupdate diffz and lsp-kit dependency
1 parent 9f916a6 commit 4ea4847

4 files changed

Lines changed: 26 additions & 21 deletions

File tree

build.zig.zon

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
.hash = "known_folders-0.0.0-Fy-PJqHJAAB43zDJmOdlr3nViu69IFI9pNFt7hkHjKk4",
2424
},
2525
.diffz = .{
26-
.url = "https://github.com/ziglibs/diffz/archive/669e6ed7470100bfd9d2aa9f6f96b93c45996179.tar.gz",
27-
.hash = "diffz-0.0.1-G2tlISLPAQDzXkUIRWWUfdgIsIb1dAyVwRPXMt5kRpui",
26+
.url = "https://github.com/ziglibs/diffz/archive/aa11caef328a3f20f2493f8fd676a1dfa7819246.tar.gz",
27+
.hash = "diffz-0.0.1-G2tlIYrNAQAQx3cuIp7EVs0xvxbv9DCPf4YuHmvubsrZ",
2828
},
2929
.lsp_kit = .{
30-
.url = "https://github.com/zigtools/lsp-kit/archive/922e9c2fc00741b167a19277d737b8eb890f0253.tar.gz",
31-
.hash = "lsp_kit-0.1.0-bi_PL94yDABlKrIbUTtVALYWLeFt6XAzHS6R12Tp83_Z",
30+
.url = "https://github.com/zigtools/lsp-kit/archive/7b03f0b6801babffe76608cf3db59793902a21d6.tar.gz",
31+
.hash = "lsp_kit-0.1.0-bi_PLw8zDABvCWe2rD4Aqb9gx0sRXBKO0a7M0vg3AbR3",
3232
},
3333
.tracy = .{
3434
.url = "https://github.com/wolfpld/tracy/archive/refs/tags/v0.13.1.tar.gz",

deps.nix

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
linkFarm "zig-packages" [
66
{
7-
name = "diffz-0.0.1-G2tlISLPAQDzXkUIRWWUfdgIsIb1dAyVwRPXMt5kRpui";
7+
name = "diffz-0.0.1-G2tlIYrNAQAQx3cuIp7EVs0xvxbv9DCPf4YuHmvubsrZ";
88
path = fetchzip {
9-
url = "https://github.com/ziglibs/diffz/archive/669e6ed7470100bfd9d2aa9f6f96b93c45996179.tar.gz";
10-
hash = "sha256-tEMWxY7jhp5OGJHejfGCkXuMtpbnp6hFetms8Zk3PYs=";
9+
url = "https://github.com/ziglibs/diffz/archive/aa11caef328a3f20f2493f8fd676a1dfa7819246.tar.gz";
10+
hash = "sha256-bdL+xLnYVzYS6T3zsw7xfLKTUCUFI0pIpQaOxV6oTis=";
1111
};
1212
}
1313
{
@@ -18,10 +18,10 @@ linkFarm "zig-packages" [
1818
};
1919
}
2020
{
21-
name = "lsp_kit-0.1.0-bi_PL94yDABlKrIbUTtVALYWLeFt6XAzHS6R12Tp83_Z";
21+
name = "lsp_kit-0.1.0-bi_PLw8zDABvCWe2rD4Aqb9gx0sRXBKO0a7M0vg3AbR3";
2222
path = fetchzip {
23-
url = "https://github.com/zigtools/lsp-kit/archive/922e9c2fc00741b167a19277d737b8eb890f0253.tar.gz";
24-
hash = "sha256-bDPbYY59HvgHtaHPfTTCqjMEx8tDJoyyld9lkONUHVY=";
23+
url = "https://github.com/zigtools/lsp-kit/archive/7b03f0b6801babffe76608cf3db59793902a21d6.tar.gz";
24+
hash = "sha256-CjWrp8fERKS5VldRvYtDFk1g4heIkX4YrpLw/eC12Q4=";
2525
};
2626
}
2727
]

src/diff.zig

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@ const offsets = @import("offsets.zig");
66
const tracy = @import("tracy");
77
const DiffMatchPatch = @import("diffz");
88

9-
const dmp: DiffMatchPatch = .{
10-
.diff_timeout = .fromMilliseconds(250),
11-
};
12-
139
pub fn edits(
10+
io: std.Io,
1411
allocator: std.mem.Allocator,
1512
before: []const u8,
1613
after: []const u8,
@@ -19,7 +16,13 @@ pub fn edits(
1916
const tracy_zone = tracy.trace(@src());
2017
defer tracy_zone.end();
2118

22-
var diffs = try dmp.diff(allocator, before, after, true);
19+
const dmp: DiffMatchPatch = .initDefault(io, allocator);
20+
var diffs = try dmp.diff(
21+
before,
22+
after,
23+
true,
24+
.{ .duration = .{ .clock = .awake, .raw = .fromMilliseconds(250) } },
25+
);
2326
defer DiffMatchPatch.deinitDiffList(allocator, &diffs);
2427

2528
var edit_count: usize = 0;

tests/utility/diff.zig

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@ fn gen(alloc: std.mem.Allocator, rand: std.Random) ![]const u8 {
88
}
99

1010
test "diff - random" {
11-
const allocator = std.testing.allocator;
1211
var rand: std.Random.DefaultPrng = .init(std.testing.random_seed);
13-
try testDiff(allocator, rand.random(), .@"utf-8");
14-
try testDiff(allocator, rand.random(), .@"utf-16");
15-
try testDiff(allocator, rand.random(), .@"utf-32");
12+
try testDiff(rand.random(), .@"utf-8");
13+
try testDiff(rand.random(), .@"utf-16");
14+
try testDiff(rand.random(), .@"utf-32");
1615
}
1716

18-
fn testDiff(allocator: std.mem.Allocator, rand: std.Random, encoding: zls.offsets.Encoding) !void {
17+
fn testDiff(rand: std.Random, encoding: zls.offsets.Encoding) !void {
18+
const io = std.testing.io;
19+
const allocator = std.testing.allocator;
20+
1921
var buffer: [256]u8 = undefined;
2022
rand.bytes(&buffer);
2123
for (&buffer) |*c| c.* = '0' + c.* % 32;
@@ -24,7 +26,7 @@ fn testDiff(allocator: std.mem.Allocator, rand: std.Random, encoding: zls.offset
2426
const before = buffer[0..split_index];
2527
const after = buffer[split_index..];
2628

27-
var edits = try zls.diff.edits(allocator, before, after, encoding);
29+
var edits = try zls.diff.edits(io, allocator, before, after, encoding);
2830
defer {
2931
for (edits.items) |edit| allocator.free(edit.newText);
3032
edits.deinit(allocator);

0 commit comments

Comments
 (0)