fix: prevent whole file filter commands from erasing the entire file

This commit is contained in:
CJ van den Berg 2025-12-10 12:25:36 +01:00
parent 693ed91b12
commit 0974935ced
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -6281,6 +6281,10 @@ pub const Editor = struct {
self.cancel_all_selections(); self.cancel_all_selections();
self.cancel_all_matches(); self.cancel_all_matches();
if (state.whole_file) |buf| { if (state.whole_file) |buf| {
if (buf.items.len == 0) {
self.logger.print_err("filter", "empty filter result", .{});
return;
}
const old_hash = blk: { const old_hash = blk: {
var content: std.Io.Writer.Allocating = .init(self.allocator); var content: std.Io.Writer.Allocating = .init(self.allocator);
defer content.deinit(); defer content.deinit();