1

I write a lot of SE questions and when I include multiple images I frequently copy/paste just the names.

I've just started using Safari on my new MacBook after using Chrome on my old MacBook, and I've discovered that when I double-tap to select the text it sometimes grabs the .jpg extension and sometimes doesn't. As far as I can tell this depends on whether the imgur filename begins with an upper case or a lower case letter.

Is there any way I can get this selection behavior to be case-agnostic?

With chrome the selection always stops before the period, but Safari seems to be more "creative" in where the selection ends.

enter image description here

enter image description here

Try it yourself!

i.stack.imgur.com/GESmi.png
i.stack.imgur.com/124RA.png
i.stack.imgur.com/eFGbq.jpg
i.stack.imgur.com/JOKd4.jpg  double tapping only selects "JOKd4" and not ".jpg"
i.stack.imgur.com/amD8b.jpg
i.stack.imgur.com/wbP9b.jpg
i.stack.imgur.com/bidkm.jpg
i.stack.imgur.com/bebR8.jpg
5
  • 1
    I can't see a pattern. JOKd4 & select the name only, the rest select the extension too. The same happens if I copy them to TextEdit
    – Tetsujin
    Aug 15, 2020 at 9:45
  • @Tetsujin interesting, thanks! I've just now tried this on my old laptop with old macOS and it happens on TextEdit there as well, but not in Chrome. So it seems this is browser-specific not OS version-specific.
    – uhoh
    Aug 15, 2020 at 9:47
  • 1
    oops, typo in my last comment - should be … "JOKd4 & bebR8 select the name only, the rest select the extension too…"
    – Tetsujin
    Aug 15, 2020 at 11:13
  • 1
    & that gave me an idea - there is a pattern. if it ends in a number it selects name only. If it ends in a letter it selects the extension too. [Spotting the pattern, however, gives me no clue as to how you might 'fix' it.]
    – Tetsujin
    Aug 15, 2020 at 11:14
  • 1
    It's the same in a url too - taking your i.stack.imgur.com/GESmi.png & changing it to i.stack.imgur1.com/GESmi.png displays the same symptom in the url part. [Double-click on stack to test.]
    – Tetsujin
    Aug 15, 2020 at 15:33

1 Answer 1

2

This is a quirk of the UAX #29 standard on Unicode word segmentation boundaries. Basically, this document specifies standard rules for determining what's a "word" in a string of Unicode text. Cocoa Text (the macOS text subsystem) conforms to these rules when implementing features like "double click to select a word".

Using uniseg, a Python library that implements these rules, we can see the word boundaries for these two strings:

In [1]: list(uniseg.wordbreak.words("JOKd4.jpg"))                                                                                 
Out[1]: ['JOKd4', '.', 'jpg']

In [2]: list(uniseg.wordbreak.words("eFGbq.jpg"))                                                                                
Out[2]: ['eFGbq.jpg']

In the first case, UAX #29 rules specify there are three words in the text (which you can check by trying to double-tap select each piece one by one). In the second case, it specifies there is only one word.

This should be standard behavior across Cocoa apps, but overridable by individual apps if they care to. Chrome, presumably, implements an override for text / word selection behavior beyond the Cocoa default. I'm not sure if there is a way for users to override this behavior without access to source code.

1
  • Wow, thank you very much for tracking this down!
    – uhoh
    Aug 16, 2020 at 0:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .