Text not editable in code block

I have had this problem for a while, where code (C++) sometimes is rendered grey and not editable (cursor jumps over the word), especially when enclosed in ().

I haven’t quite figured out when exactly this happens, but maybe someone knows why and hopefully even a fix or workaround. Thanks in advance!

image