From e36968b3130fbf2482fe0181b60f02dc51f60fd1 Mon Sep 17 00:00:00 2001 From: MiMoHo <37556964+MiMoHo@users.noreply.github.com> Date: Fri, 3 Jul 2026 21:00:45 +0200 Subject: [PATCH] fix: correct spacing in contact display names getNameToDisplay() glued the suffix's leading ", " onto the last name inside a single list element ("$lastPart$suffixComma"). When the last name was empty, that element was non-blank (", "), so the isNotBlank() filter kept it and joinToString(" ") prepended a stray space before the comma (e.g. "John , Jr", "Smith , Jr", "Dr , Jr"). Make lastPart its own filterable list element and append the suffix comma after the join, so an empty last name is dropped and the suffix comma is never preceded by a stray space. Fixes FossifyOrg/Contacts#157. --- .../kotlin/org/fossify/commons/models/contacts/Contact.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commons/src/main/kotlin/org/fossify/commons/models/contacts/Contact.kt b/commons/src/main/kotlin/org/fossify/commons/models/contacts/Contact.kt index 9b7ebfcae1..416bfe8a45 100644 --- a/commons/src/main/kotlin/org/fossify/commons/models/contacts/Contact.kt +++ b/commons/src/main/kotlin/org/fossify/commons/models/contacts/Contact.kt @@ -173,9 +173,9 @@ data class Contact( } val lastPart = if (startWithSurname) firstMiddle else surname val suffixComma = if (suffix.isEmpty()) "" else ", $suffix" - val fullName = listOfNotNull(prefix, firstPart, "$lastPart$suffixComma") + val fullName = listOfNotNull(prefix, firstPart, lastPart) .filter { it.isNotBlank() } - .joinToString(" ") + .joinToString(" ") + suffixComma val organization = getFullCompany() val email = emails.firstOrNull()?.value?.trim() val phoneNumber = phoneNumbers.firstOrNull()?.normalizedNumber