fix: remove stray space before suffix in contact display name#359
Closed
MiMoHo wants to merge 1 commit into
Closed
fix: remove stray space before suffix in contact display name#359MiMoHo wants to merge 1 commit into
MiMoHo wants to merge 1 commit into
Conversation
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 (", <suffix>"), 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of change(s)
What changed and why
Contact.getNameToDisplay()built the display name aslistOfNotNull(prefix, firstPart, "$lastPart$suffixComma").filter { it.isNotBlank() }.joinToString(" "). The.filter { isNotBlank() }already fixed the double space from an empty middle part (e.g. prefix + surname only), but when the last name is empty and a suffix is present, the third element becomes", <suffix>"— which is not blank, so it survives the filter andjoinToString(" ")prepends a stray space, e.g.John , Jr/Smith , Jr.Fix: make
lastPartits own filterable element and append the suffix after the join, so an empty last name is dropped and the suffix comma is never preceded by a stray space.This lives in commons because
getNameToDisplay()is shared; it fixes the display name in Fossify Contacts and Phone (contact rows, details header, shortcuts, letter avatars).Tests performed
Verified the pure
getNameToDisplay()string logic against the reported and adjacent cases (before → after):John+ suffixJr:John , Jr→John, JrSmith+ suffixJr:Smith , Jr→Smith, JrDr+ surnameSmith:Dr Smith(unchanged)Dr John Smith Jr:Dr John Smith, Jr(unchanged)./gradlew :commons:detekt :commons:lintRelease :commons:assembleReleaseall pass locally. (commons has no unit-test source set, so this is a static/logic verification.)Related issue(s)
Checklist
Coded with Opus 4.8 ultracode.