Guard bare > stripping with has_prompt check
This commit is contained in:
parent
b81bc3edc8
commit
fd977b91a2
1 changed files with 4 additions and 1 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue