2025-08-23 Sat 23:13 Piece table How is it that now after spending so much time on my text editor I'm finding all those resources that would be very helpful and interesting back when I started. Few years ago when I was actively researching the topic it was impossible to find anything beyond few small projects with line based editing. But now everything is screaming at me that gap buffer might not be the right choice. I just learned about the Piece table [1] which at first sounded awful but after longer consideration I admit that it has more than one nice property. One of which is that undo history is almost for free. Then there is this blog post [2] linking to yet another resources which talk about VS code approach to text buffer [3] and criticism of gap buffer [4] which apparently is no good for multi cursor edits. Well I have not got to the point of implementing history and multiple cursors in my text editor development journey. It might just be that macro system that I will make will made multiple cursors obsolete and most probably the advantage of easy undo history in piece table will not work with files as big as few GB which my editor suppose to handle. We will see. What strikes me the most is that piece table looks almost exactly like undo history session structure I designed with my brother during random discussion on the topic. It's not the first time when someone reinvents something. Looks like given certain design decisions, limitations and constrains the solution presents itself. > I find, that if I just sit down to think... > The solution presents itself! > - Professor Henry Jones [1] https://en.wikipedia.org/wiki/Piece_table [2] https://cdacamar.github.io/data%20structures/algorithms/benchmarking/text%20editors/c++/editor-data-structures/ [3] https://code.visualstudio.com/blogs/2018/03/23/text-buffer-reimplementation [4] https://nullprogram.com/blog/2017/09/07/ EOF