prompt-toolkit / pyvim

Pure Python Vim clone.
BSD 3-Clause "New" or "Revised" License
2.52k stars 160 forks source link

Strange behavior when deleting an empty line in visual mode #110

Closed davidbrochart closed 6 years ago

davidbrochart commented 6 years ago

Launch pyvim and enter the following lines (line 2 is empty):

qwe

asd

On line 1, Shift-v then j then d, this deletes only line 1. u to undo. On line 2, Shift-v then d, this deletes line 1 and 2. Also generally, on the last line of a file, Shift-v then d doesn't remove the line, it just clears it.

This was there before prompt-toolkit 2.0.

jonathanslenders commented 6 years ago

Hi @davidbrochart, That should be fixed here: https://github.com/jonathanslenders/python-prompt-toolkit/commit/8cb130d03b986ca4ed68905823279bd8e8b16458 Could you try again please? Thanks!

jonathanslenders commented 6 years ago

The last line is a special case, I'm not considering yet. This is because prompt_toolkit considers the final line ending at the very end of the file, the start of yet another line. So, in a sense, it doesn't enforce files to have a line ending at the end. This is coming from the way prompts are working, maybe at some point I'll fix that for pyvim.

davidbrochart commented 6 years ago

Works like a charm, thanks!

jonathanslenders commented 6 years ago

One small change, this is the final commit, because another unit test was broken. This should do it: https://github.com/jonathanslenders/python-prompt-toolkit/commit/a54fc0bd7579b11e290ccd4d70037d68c92f7be3