Fix line callbacks not firing when no filter_lines set

The line buffering and callback processing only ran when a filter
pattern was configured. Enter the line processing branch whenever
line_callbacks are registered too.
This commit is contained in:
J. Nick Koston
2026-03-06 22:04:43 -10:00
parent 06ac17e443
commit 0e7d4d8301
+5 -2
View File
@@ -162,7 +162,7 @@ class RedirectText:
if not isinstance(s, str):
s = s.decode()
if self._filter_pattern is not None:
if self._filter_pattern is not None or self._line_callbacks:
self._line_buffer += s
lines = self._line_buffer.splitlines(True)
for line in lines:
@@ -174,7 +174,10 @@ class RedirectText:
line_without_ansi = ANSI_ESCAPE.sub("", line)
line_without_end = line_without_ansi.rstrip()
if self._filter_pattern.match(line_without_end) is not None:
if (
self._filter_pattern is not None
and self._filter_pattern.match(line_without_end) is not None
):
# Filter pattern matched, ignore the line
continue