aligrudi / neatvi

A small vi/ex editor for editing bidirectional UTF-8 text

Home Page:http://litcave.rudi.ir/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

^y ^e keys cursor pos mismatch

kyx0r opened this issue · comments

commented

@aligrudi xcol is not updated because mod is set to 0, but xoff is being changed.

The following commit in my fork fixes the bug.
kyx0r/nextvi@a408170

Also take a note that the function vi_scrollforeward() has a typo, (should be vi_scrollforward) I addressed that in future commits.

commented

@aligrudi There can be technically 2 solutions to this, either 1: update xcol, 2: update xoff. In my solution I update xoff based on xcol, that basically makes visual cursor pos have correct offset. If you update xcol instead, it will be equivalent to lbuf_indents() position. I think updating xoff is right solution here because cursor should be on the same visual pos as the previous line.

Regards,
Kyryl

commented

@aligrudi It's easy to reproduce, you just have to place the cursor onto a longer string than the next string above it, test using ^y
you can clearly see on this screenshot that the output of ga does not match where the cursor is.

see it here: https://0x0.st/-vSO.png

commented

Yep, that's what I did in my fork, also the if statement on vi_scroll* is redundant because it calls MAX and MIN so it can never go out of bounds. I'll clean up all rest of those if statements later in my fork. And having if statement that will never be true in 99% of the time no worth the hassle.

commented

Applied. If the if statement is removed, the position of cursor changes with ^b at the beginning of file. Ali

Right, but that seems too far from a realistic use case scenario. The user would need to make a conscious decision to move the cursor from the indent position and then try to go up using ^b. In this scenario doing nothing or changing cursor pos, is equivalent to doing nothing, because the operation itself is undefined behavior pedantically speaking. And different vi implementations do different things in those cases.