I’m in the process of trying to make it so that TaskPaper remembers folded items even when the document is edited outside of TaskPaper.
I think to do this I’ll need to track items by line number and text content in a fuzzy way. I want to restore the “folded” items even if another editor inserts lines or edits some text.
In this case errors aren’t the end of the world, collapsed state will just be off. But generally it should work for reasonable edits. I think my solution would look like:
- Hash each folded item’s line number, type, and text content
- For each saved hash find the closest matching item in the loaded document and collapse it.
I’m looking for that magic hash function.
I see “Locality-sensitive hashing” on WikiPedia and the description sound hopeful. But it’s a complex subject and I’d like to get pointed in the right direction. Can anyone suggest the simplest most strait forward solution to this problem… How to track individual lines in a plain text file that may be edited by others?