Guard bare > stripping with has_prompt check

This commit is contained in:
Jared Miller 2026-02-10 17:53:11 -05:00
parent b81bc3edc8
commit fd977b91a2
Signed by: shmup
GPG key ID: 22B5C6D66A38B06C

View file

@ -38,12 +38,15 @@ class EmbeddedIFSession:
def _strip_prompt(self, output: str) -> str:
"""Strip trailing > prompt from game output (matches dfrotz behavior)."""
has_prompt = (
output.endswith("> ") or output.endswith(">\n") or output.endswith(">\r\n")
)
text = output.rstrip()
if text.endswith("\n>"):
return text[:-2].rstrip()
if text == ">":
return ""
if text.endswith(">"):
if has_prompt and text.endswith(">"):
return text[:-1].rstrip()
return output