gchp/iota

Marks & MarkPosition and how are they kept valid?

Opened this issue · 0 comments

I'm sorry if this is a completely inappropriate place to take up my questions regarding some things in this text editor, but I can't seem to find any description of how the thought process was when designing this text editor (and I can't contact the owner of the repo directly).

I kind of understand the idea behind the Mark and MarkPosition, but what makes me bewildered is, the Buffer Struct contains a HashMap with marks in it - how is this kept valid at all, when insertion and deletion of characters in the buffer is made? I can't seem to find anything in the source code either, or maybe I am completely missing the purpose of this all together?

Since it indexes into the GapBuffer (and since GapBuffer is a 1D array, basically) through an absolute index, any insertion or deletion before a mark, will completely invalidate it, if no update is made to that entry in the hashmap, at every insertion and deletion, which (if many marks are saved) could lead to quite the overhead, no?

Or what is the purpose of this HashMap, at first, I thought I thought it was some container for keeping track of positions in the text, (like a bookmarking feature the end user can use, hence my question on validation of the marks and their purpose). But after looking through the source code, that doesn't seem to be it's purpose neither. Could you be so kind and explain briefly to me the purpose of that HashMap?

Anyway, awesome project, has me inspired to writing my own rusty project.