Jump to content

Extra Space in Contact Names [Fixed 4.1.1 b1168 pre-release]


Recommended Posts

Posted

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. 

Screen Shot 2020-07-07 at 3.09.50 PM.png

Posted

@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

Posted

@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 changed the title to Extra Space in Contact Names [Fixed in Alfred 4.1 b1167]
Posted
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.

Posted
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

Posted

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.

Posted

@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 changed the title to Extra Space in Contact Names
  • 3 weeks later...
  • Andrew changed the title to Extra Space in Contact Names [Fixed 4.1.1 b1168 pre-release]

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...