Seems like triazotan has a solution involving replacing non breaking space for space https://stackoverflow.com/a/20129483/1247248
rednaw has some potentially better version, but someone was complaining of weird side effects https://stackoverflow.com/a/22512184/1247248
I ended up going with the version of this solution suggested by meaning-matters https://stackoverflow.com/a/22211018/1247248 and that worked for me.
EDIT
It looked like a good fix but I found a problem. When you select inside the text and type the cursor jumps to the end of the line. Turns out I should have gone with triazotan's version https://stackoverflow.com/a/20129483/1247248