gchp / iota

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

Fix undo/redo cursor positions #70

Open pythonesque opened 9 years ago

pythonesque commented 9 years ago

It seems like the "after" cursor isn't being set correctly currently, so when you redo the cursor ends up in the wrong place (i.e. not the place it was before the edit began). Seems like this should be an easy fix.

pythonesque commented 9 years ago

Also, it looks like the "fix undo/redo across pages" fix was reverted (or at least, it no longer appears to be working, as the screen doesn't scroll properly).

withoutboats commented 9 years ago

"when you redo the cursor ends up in the wrong place (i.e. not the place it was before the edit began)."

Is this actually the wrong place? It ends up where the redo occurred, which is the same behavior that I get in gedit and vim (my vimrc is unmodified from whatever is installed on Ubuntu 14.04). It is trivial to change (just reset the end_point when the buffer's undo and redo methods are handling the transaction), but I'm not sure what we want.

The other change is also trivial, I'll push a fix. EDIT: Of course, not actually trivial. But I'll roll that fix into fixing horizontal scrolling.

pythonesque commented 9 years ago

Hm, you seem to be right about vim's default behavior. It intuitively feels wrong to me (shouldn't redoing put your cursor where it was after the edit, not before it?) but maybe I am the one who's wrong here.

withoutboats commented 9 years ago

It does put the cursor where it was after the edit, just not after the additional actions of shifting the cursor's position. When we create transactions that include larger blocks than single insertions and removals, we can incorporate cursor movements into the transaction (probably optionally).

pythonesque commented 9 years ago

Cursor movements were already incorporated into the transaction before, so this is a behavior change for sure. But I can definitely understand the perspective that they aren't part of the edit.

gchp commented 9 years ago

Still seeing some weird behaviour with this.

The cursor should be positioned like so: tes|t Instead, it is positioned like this: te|st.

Seems off by one every time.

gchp commented 9 years ago

Perhaps the wrong value is being stored in transaction.end_point?