fix: _trim_to_letter_end matches full name when no profile set

When _profile is None the fallback pattern \w+ only matched the first
word of a two-word sign-off (e.g. 'Alex' from 'Alex Rivera'), silently
dropping the last name. Switch fallback to \w+(?:\s+\w+)? so a full
first+last sign-off is preserved in no-config environments (CI, first run).
This commit is contained in:
pyr0ball 2026-03-15 16:43:27 -07:00
parent 062f249ef9
commit 922ede9258

View file

@ -221,7 +221,7 @@ def _trim_to_letter_end(text: str) -> str:
candidate_first = (_profile.name.split()[0] if _profile else "").strip() candidate_first = (_profile.name.split()[0] if _profile else "").strip()
pattern = ( pattern = (
r'(?:Warm regards|Sincerely|Best regards|Kind regards|Thank you)[,.]?\s*\n+\s*' r'(?:Warm regards|Sincerely|Best regards|Kind regards|Thank you)[,.]?\s*\n+\s*'
+ (re.escape(candidate_first) if candidate_first else r'\w+') + (re.escape(candidate_first) if candidate_first else r'\w+(?:\s+\w+)?')
+ r'\b' + r'\b'
) )
m = re.search(pattern, text, re.IGNORECASE) m = re.search(pattern, text, re.IGNORECASE)