fix: preserve ansi output history on resize replay
This commit is contained in:
9
cli.py
9
cli.py
@@ -1415,9 +1415,6 @@ _OUTPUT_HISTORY_REPLAYING = False
|
||||
_OUTPUT_HISTORY_SUPPRESSED = False
|
||||
_OUTPUT_HISTORY_MAX_LINES = 200
|
||||
_OUTPUT_HISTORY = deque(maxlen=_OUTPUT_HISTORY_MAX_LINES)
|
||||
_ANSI_CONTROL_RE = re.compile(
|
||||
r"\x1b(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~]|\][^\x07]*(?:\x07|\x1b\\))"
|
||||
)
|
||||
|
||||
|
||||
def _coerce_output_history_limit(value) -> int:
|
||||
@@ -1459,10 +1456,10 @@ def _record_output_history_entry(entry) -> None:
|
||||
def _record_output_history(text: str) -> None:
|
||||
if not _OUTPUT_HISTORY_ENABLED or _OUTPUT_HISTORY_REPLAYING or _OUTPUT_HISTORY_SUPPRESSED:
|
||||
return
|
||||
clean = _ANSI_CONTROL_RE.sub("", str(text)).replace("\r", "").rstrip("\n")
|
||||
if not clean:
|
||||
normalized = str(text).replace("\r", "").rstrip("\n")
|
||||
if not normalized:
|
||||
return
|
||||
for line in clean.splitlines():
|
||||
for line in normalized.splitlines():
|
||||
_record_output_history_entry(line)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user