Complete shortcut in Messages on OS X
It’s a text autocomplete feature. You can type when and press Esc to shows all the available words. It’s available everywhere, not just Messages. But somehow Messages doesn’t act according to its function, I believe it’s a bug, or Messages uses different frameworks for the text field.