Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Marks & MarkPosition and how are they kept valid? #151

Open
theIDinside opened this issue Mar 1, 2019 · 0 comments
Open

Marks & MarkPosition and how are they kept valid? #151

theIDinside opened this issue Mar 1, 2019 · 0 comments

Comments

@theIDinside
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant