Inline LaTeX - escaped curly braces cause codemirror to leave math mode

Interestingly, if you type another inline block after one of these blocks, they all display correctly. For example the following will show in the editor with the correct CSS classes applied:

$\{ \}$ something something $x$