Hacker News new | ask | show | jobs
by samwillis 1283 days ago
That list of formatting sequences would have to be updated with new indexes when the content of the buffer changed. Keeping the two in sync wouldn't be trivial (for a computer or a human), a tree of nodes fixes that and works for 99.99% of use cases.
1 comments

It may not be trivial, but it's a solved problem. Many rich text UI widgets and corresponding backing data structures exist today, based on a tagging system where tags can trivially define regions that overlap with each other. It's tricky and full of corner cases, but not that hard if you put your mind to it, and it's not computationally inefficient either.