mirror of
https://github.com/pdxlocations/contact.git
synced 2026-07-27 12:02:33 +02:00
Fix reply prefix logic to prevent nesting existing reply markers and update tests accordingly
This commit is contained in:
@@ -180,7 +180,8 @@ def build_reply_prefix(prefix: str, message: str) -> str:
|
||||
sender_text = re.sub(r"^(?:>>|<<)\s*(?:\[[^]]+\]\s*)?", "", sender_text)
|
||||
sender_match = re.search(r"(.+?)\s*:\s*$", sender_text)
|
||||
sender = sender_match.group(1).strip() if sender_match else "me"
|
||||
excerpt = " ".join(message.replace("\x00", "").split())[:REPLY_EXCERPT_LENGTH]
|
||||
message_without_reply_marker = re.sub(r"^<Re:\s*[^>]*>\s*", "", message.replace("\x00", ""))
|
||||
excerpt = " ".join(message_without_reply_marker.split())[:REPLY_EXCERPT_LENGTH]
|
||||
return f"<Re: {sender}: {excerpt}> "
|
||||
|
||||
|
||||
|
||||
@@ -120,6 +120,14 @@ class ContactUiTests(unittest.TestCase):
|
||||
|
||||
self.assertEqual(reply, "<Re: LRY: Thank> ")
|
||||
|
||||
def test_build_reply_prefix_does_not_nest_an_existing_reply_marker(self) -> None:
|
||||
reply = contact_ui.build_reply_prefix(
|
||||
"[06:27:25] >> xT1e: ",
|
||||
"<Re: CATS: Woot!> Woot indeed",
|
||||
)
|
||||
|
||||
self.assertEqual(reply, "<Re: xT1e: Woot > ")
|
||||
|
||||
def test_handle_ctrl_r_prefills_reply_for_message_at_cursor(self) -> None:
|
||||
ui_state.current_window = 1
|
||||
ui_state.channel_list = ["Primary"]
|
||||
|
||||
Reference in New Issue
Block a user