From what I have tested on my Xbox when I go to re-edit one of the following items: command blocks, chat messages, chat commands, or renaming items in anvils, all the text you typed after the spot you edited gets deleted.
Note: from what I have tested book and quills seem to be unaffected by this bug.
Note: I did see a post about the same bug earlier, however that post seemed a bit unclear. So I reposted the same bug with a bit more information and clarity.
Thank you for your report!
We're tracking this issue in MCPE-172835, so this ticket is being resolved and linked as a duplicate.
If you would like to add a vote and any extra information to the main ticket it would be appreciated.
Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki