millerstevew Posted July 7, 2020 Posted July 7, 2020 I'm almost certain that this has something to do with my contact database, but I haven't the foggiest what about my contacts would cause this to happen. Most, though not all, of my contacts are returning with two spaces between the first and last name. (See attached.) As far as I can tell, there doesn't appear to be a middle name value for these contacts.
vitor Posted July 8, 2020 Posted July 8, 2020 Welcome @millerstevew, Have you checked if the contact’s names themselves have spaces in them, in the Contacts app?
Andrew Posted July 8, 2020 Posted July 8, 2020 @millerstevew Alfred doesn't trim the name data from the Address Book API, so there will be either a space for a middle name in one of these contacts, or a trailing space. I will make a quick change for 4.1 to trim the whitespace from names which will fix this in Alfred's contact viewer. It will also fix it in Alfred's default results mode if using the default mode of not using the Spotlight index to find contacts. Interestingly, while testing this, Contacts.app was extremely awkward (buggy) in letting me remove a middle name, insisting it would stay as a single space (this may be where your issue stems from), and Spotlight showed this middle space in my contact name too. Only after perseverance, I managed to remove the middle name space. it's probably best you try to fix these contacts Cheers, Andrew
millerstevew Posted July 9, 2020 Author Posted July 9, 2020 @Andrew Thanks for the very thoughtful response. I've checked Contacts.app (and BusyContacts FWIW) and neither of them display a middle name with a space in it. That said, if I add a middle name to these effected contacts and then remove it, the extra white space in Alfred magically disappears. This tells me that Contacts.app (and perhaps BusyContacts) are trimming spaces. (Or maybe it has to do with the APIs they use... I'm not a developer, so I can't speak with authority, I vaguely remember a developer complaining about the contacts API on a podcast in the last year or two.) I would very much appreciate if you make Alfred trim these spaces in future builds, and if you have any ideas on how to remove these spaces from my concats without going through one-by-one, I'd love to know any thoughts you have. Love the great app! It's indispensable in my workflow.
Andrew Posted July 10, 2020 Posted July 10, 2020 @millerstevew if you update to Alfred 4.1, these names should now be trimmed
millerstevew Posted July 10, 2020 Author Posted July 10, 2020 (edited) I hate to be annoying, but I just updated, and I'm still noticing the issue. Any thoughts? Edited July 10, 2020 by millerstevew
deanishe Posted July 10, 2020 Posted July 10, 2020 19 hours ago, millerstevew said: That said, if I add a middle name to these effected contacts and then remove it, the extra white space in Alfred magically disappears. It does sound awfully like some of your contacts have a middle name set to an empty space. Have you tried opening one of the affected contacts in Contacts.app, exporting it as a vCard and checking what’s in the name (N:) field? (Open the vCard in a text editor.) A contact with no middle name should look like this: N:Lastname;Firstname;;; If there’s a space for a middle name, it will look like this: N:Lastname;Firstname; ;; (i.e. the third field will be empty) You might also be able to see the problem in the full name field (FN:). 20 hours ago, millerstevew said: if you have any ideas on how to remove these spaces from my concats without going through one-by-one, I'd love to know any thoughts you have. It's possible to write a script that loops through all your contacts and fixes the borked ones. I can probably help you with that, but you'd need to figure out how your contact data are messed up before they can be fixed.
millerstevew Posted July 11, 2020 Author Posted July 11, 2020 This is really bizarre. I open the vCard and there are no spaces in the problematic contacts. Any more thoughts? I thought for sure this would be the issue.
deanishe Posted July 11, 2020 Posted July 11, 2020 4 hours ago, millerstevew said: Any more thoughts? Try running this AppleScript in Script Editor. Make sure the “Messages” or “Results” tab of the log is visible (View > Show Log). What does it say? tell application "Contacts" to log middle name of person "Dan Gilbert" as text
Andrew Posted July 11, 2020 Posted July 11, 2020 Very strange! Are you seeing the middle name space in Alfred's contact viewer too? I'm gonna make a further change for 4.1.1 to be even more "defensive" against unexpected or bad data coming back from the API which may help.
millerstevew Posted July 11, 2020 Author Posted July 11, 2020 @Andrew I am seeing the extra space in Alfred's contact viewer. @deanishe I tried your suggestion and Contacts isn't returning a middle name. I also tried returning the first name and it doesn't look like there's a trailing space on the contact "Dan Gilbert" either.
Andrew Posted August 4, 2020 Posted August 4, 2020 @millerstevew could you please update to the 4.1.1 pre-release and let me know if those spaces are now gone? Cheers, Andrew
millerstevew Posted August 4, 2020 Author Posted August 4, 2020 (edited) @Andrew They are all gone! Thanks so much. Edited August 4, 2020 by millerstevew
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now