From bad1ededc1789fde26ff3205a1fe19a52373e931 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Wed, 14 Jan 2026 18:11:18 +0100 Subject: [PATCH] fix: handle filter output only in editors with a filter running Not a perfect solution because filters could theoretically be running in multiple editors at once. But for now it a least fixes things for splits without forcing a full filter code re-write. --- src/tui/editor.zig | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/tui/editor.zig b/src/tui/editor.zig index 1c7f439..cd4c823 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -6470,6 +6470,10 @@ pub const Editor = struct { state.work_root = try state.work_root.delete_range(sel, buf_a_, null, self.metrics); } + fn is_filter_running(self: *const Self) bool { + return self.filter_ != null; + } + fn filter_stdout(self: *Self, bytes: []const u8) !void { const state = if (self.filter_) |*s| s else return error.Stop; errdefer self.filter_deinit(); @@ -6877,13 +6881,13 @@ pub const EditorWidget = struct { try self.mouse_drag_event(event, @enumFromInt(btn), y, x, ypx, xpx); } else if (try m.match(.{ "scroll_to", tp.extract(&pos) })) { self.editor.scroll_to(pos); - } else if (try m.match(.{ "filter", "stdout", tp.extract(&bytes) })) { + } else if (self.editor.is_filter_running() and try m.match(.{ "filter", "stdout", tp.extract(&bytes) })) { self.editor.filter_stdout(bytes) catch {}; - } else if (try m.match(.{ "filter", "stderr", tp.extract(&bytes) })) { + } else if (self.editor.is_filter_running() and try m.match(.{ "filter", "stderr", tp.extract(&bytes) })) { try self.editor.filter_error(bytes); - } else if (try m.match(.{ "filter", "term", "error.FileNotFound", 1 })) { + } else if (self.editor.is_filter_running() and try m.match(.{ "filter", "term", "error.FileNotFound", 1 })) { try self.editor.filter_not_found(); - } else if (try m.match(.{ "filter", "term", tp.more })) { + } else if (self.editor.is_filter_running() and try m.match(.{ "filter", "term", tp.more })) { try self.editor.filter_done(); } else if (try m.match(.{ "A", tp.more })) { self.editor.add_match(m) catch {};