Android Gboard undo mangles contents in certain cases

I’m just wondering if this is known or not and if there’s anything that can theoretically be done to remedy this?

I had thought this worked when I did some brief testing several weeks back. I’m not sure if my testing was too cursory or if GBoard’s behavior changed. I know some of its behaviors have changed recently, and I’m not sure if this might have affected undo operations.

Is it expected that the gBoard undo would cause varying degrees of mangling of the document? I was under the impression these undo events adhered to some standard. I’m away at the moment so I can’t check the input event types, but it definitely isn’t handled gracefully in the majority of cases I’ve used it in our editor.