If you are interested in this kind of stuff, Craig Finseth's The Craft of Text Editing is a great read: https://www.finseth.com/craft/
That will make a good weekend read thanks! Others may be interested in Data Structures for Text Sequences by Charles Crowley[0] which describes Piece Tables. This is the basis for the Vis editor[1].