gchp / iota

A terminal-based text editor written in Rust
MIT License
1.63k stars 81 forks source link

Adding undo and redo. #59

Closed pythonesque closed 9 years ago

pythonesque commented 9 years ago

This involves adding transactional semantics to all commands that modify data. This is explicitly not optimized right now, but is instead as simple as possible. If it proves damaging in the immediate term, we can easily bound the size of the undo/redo stack.

Undo/redo are CTRL + Z and CTRL + Y. As far as I can tell, they work, with no caveats.

This builds off the commit that fixes deletion at end of line.

pythonesque commented 9 years ago

BTW, a back of the envelope calculation tells me it's unlikely even this wasteful format will take up very much space (conservatively, maybe 20 MB for 80,000 edits in the undo buffer?) So I wouldn't worry about it for now.

gchp commented 9 years ago

This is nice.

Like you said in Gitter, this will need some kind of identifier which will split history for different buffers. But seeing as we can only have one buffer at a time right now its not so much of an issue :)

Good idea on the distinction between Cursor and CursorData, too.

gchp commented 9 years ago

Is this the transaction model you see being used for all edits to the buffer?

pythonesque commented 9 years ago

It's an inefficient rough draft, and there are some details that differ (we currently write to the view before the transaction log, while in the future we will write to the transaction log first), but this is roughly the low-level representation idea.