News for hackers. Stuff that matters.
Re:Microsoft is updating Notepad by ars on Thursday July 12, 2018 @08:10PM (#17519638)
You use a https://en.wikipedia.org/wiki/Rope_(data_structure) and not a flat string.

You only flatten the string when it's time to write to disk.

For autosave files make sure to store the changes to the rope, not the full text.

Re:Microsoft is updating Notepad by lighttower on Thursday July 12, 2018 @10:50PM (#17520170)
There is a comment somewhere on HN from the guy that wrote the mapping trick that Word (or WordPerfect) invented way back. They were saving changes to the file rather than flattening. I wish I could find it now.
Re:Microsoft is updating Notepad by ygra on Friday July 13, 2018 @01:02AM (#17520633)
The data structure is called a piece table, if that ids your search.
Re:Microsoft is updating Notepad by pkaye on Friday July 13, 2018 @05:39PM (#17526955)
According to Wikipedia, it looks like Visual Studio Code is using this data structure.