This bug is in 2021 still present in Gboard. I think, it might be related to autosuggestions and autocorrection, but I didn't verify that so far. AFAIK apps could turn off specific features of an IME. This is writers vs. coders mode.
But I use Simple Keyboard or OpenBoard now as my keyboards for scripting in Automagic.
Post your questions and help other users.