preservim / vim-markdown

Markdown Vim Mode
4.69k stars 524 forks source link

Cursor position lost when moving from long lines to shorter lines #626

Open Bekaboo opened 1 year ago

Bekaboo commented 1 year ago

Hi, thanks for your great work on this plugin!

I noticed a bug: when I move from a long line with cursor at, say, column 10, to a shorter line with length less than 10, the memorized largest horizontal cursor position will be "reset" to the horizontal position of the cursor on the shorter line, and will never come back to 10 after if the cursor is moved to a longer line.

To better explain the difference between the expected (default) behavior and the actual behavior, I make two screen recordings:

My suggestion is that it might be problem from setting window options on event CursorMoved, this can be considered as a vim bug, but currently it is possible to be effectively fixed by using winsaveview() and vinresetview(), to see why, please check the discussions here.