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:
|
def _strip_prompt(self, output: str) -> str:
|
||||||
"""Strip trailing > prompt from game output (matches dfrotz behavior)."""
|
"""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()
|
text = output.rstrip()
|
||||||
if text.endswith("\n>"):
|
if text.endswith("\n>"):
|
||||||
return text[:-2].rstrip()
|
return text[:-2].rstrip()
|
||||||
if text == ">":
|
if text == ">":
|
||||||
return ""
|
return ""
|
||||||
if text.endswith(">"):
|
if has_prompt and text.endswith(">"):
|
||||||
return text[:-1].rstrip()
|
return text[:-1].rstrip()
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue