When you have a text sentence, you likely know that you can double-click on any word to select it. That is very convenient and I personally use it a lot.
To have a little bit of background, I also want to share my inspiration of this question. It is inspired by the xkcd comic #2109, which as explained in the corresponding community wiki pokes fun at a different kind of accidental selection errors. The "solution" for the error presented there could be e.g. the well-known double-click to select a word. (On Windows it still seems to be a common behavior to also select the following space, which makes this a non-solution in this case.)
Now what happens if I double-click on a space instead of a word? Or, what should happen UX-wise?
IMHO this is a thing that may only happen accidentally, but that is another debate I don't want to start right now. At least this is how it happened to me personally, so I'd say users may generally want to select either the word before or after the text and were a bit "off" with their cursor.
How applications currently handle it
I looked a bit into how other application do it. Here are my findings:
- The simple way (e.g. gedit, Chrome/ium, GNOME Terminal, Notepad++): Just select the space.
- As LibreOffice Writer: (Seems to) Always select the next word.
As Firefox on Linux (GNOME): Select previous and following word, which however results in punctuation also being treated and selected as a "word".
- Usual behavior on Windows, as it seems, is to select previous word and space afterwards (e.g. MS Office, Windows search input field, notepad.exe, Firefox on Windows) as it is anyway also done when you double-click on the word itself (see the already linked UX question).
Other possibilities I can see:
- Randomly select a word based on the idea clicking the space was a mistake anyway.
- Approximate word to select based on click point based on the same idea, but more consistent result based on where you clicked, can be a very tiny calculation however, but for more spaces or tabs it could be useful.
- Do nothing at all, i.e. select nothing as you think this is a user error.