diff options
| author | Doclic <doclic@tutanota.com> | 2023-10-19 01:21:52 +0200 |
|---|---|---|
| committer | Doclic <doclic@tutanota.com> | 2023-10-19 01:21:52 +0200 |
| commit | 206bb2e713a2acc560dfd9a6f04c2961d62fac7e (patch) | |
| tree | 691408c648e942dab1140e1fd8947ffbce12a4dc | |
| parent | ad1e0aa75232a63122c2e4a45b260d2fcae97aad (diff) | |
| download | river-206bb2e713a2acc560dfd9a6f04c2961d62fac7e.tar.gz river-206bb2e713a2acc560dfd9a6f04c2961d62fac7e.tar.xz | |
river: make RuleList return deleted items
| -rw-r--r-- | river/command/rule.zig | 6 | ||||
| -rw-r--r-- | river/rule_list.zig | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/river/command/rule.zig b/river/command/rule.zig index 33b9b3b..a2dc9da 100644 --- a/river/command/rule.zig +++ b/river/command/rule.zig @@ -105,13 +105,13 @@ pub fn ruleDel(_: *Seat, args: []const [:0]const u8, _: *?[]const u8) Error!void switch (action) { .float, .@"no-float" => { - server.config.float_rules.del(.{ + _ = server.config.float_rules.del(.{ .app_id_glob = app_id_glob, .title_glob = title_glob, }); }, .ssd, .csd => { - server.config.ssd_rules.del(.{ + _ = server.config.ssd_rules.del(.{ .app_id_glob = app_id_glob, .title_glob = title_glob, }); @@ -119,7 +119,7 @@ pub fn ruleDel(_: *Seat, args: []const [:0]const u8, _: *?[]const u8) Error!void server.root.applyPending(); }, .tag => { - server.config.tag_rules.del(.{ + _ = server.config.tag_rules.del(.{ .app_id_glob = app_id_glob, .title_glob = title_glob, }); diff --git a/river/rule_list.zig b/river/rule_list.zig index 1083018..ad6fbf8 100644 --- a/river/rule_list.zig +++ b/river/rule_list.zig @@ -82,17 +82,17 @@ pub fn RuleList(comptime T: type) type { }); } - pub fn del(list: *Self, rule: struct { app_id_glob: []const u8, title_glob: []const u8 }) void { + pub fn del(list: *Self, rule: struct { app_id_glob: []const u8, title_glob: []const u8 }) ?T { for (list.rules.items, 0..) |existing, i| { if (mem.eql(u8, rule.app_id_glob, existing.app_id_glob) and mem.eql(u8, rule.title_glob, existing.title_glob)) { util.gpa.free(existing.app_id_glob); util.gpa.free(existing.title_glob); - _ = list.rules.orderedRemove(i); - return; + return list.rules.orderedRemove(i).value; } } + return null; } /// Returns the value of the most specific rule matching the view. |
