dstein64 / nvim-scrollview

A Neovim plugin that displays interactive vertical scrollbars and signs.
MIT License
546 stars 10 forks source link

Cursor positions changes undeterminably while scrolling past it #127

Closed MikeLemo1 closed 7 months ago

MikeLemo1 commented 9 months ago

When I scroll and go part the cursor it changes/drags the Cursor position with it out of the initial state. Is there a way to make it stay steady?

dstein64 commented 9 months ago

Hi @MikeLemo1, can you provide steps to reproduce the issue? Is this for ordinary scrolling with the keyboard? If so, which keys are you pressing? Or is this for scrolling some other way (e.g., dragging scrollbars with the mouse)?

MikeLemo1 commented 9 months ago

Hi there @dstein64 Actually yeah it is scrolling with the mouse but I'd still like the cursor to be static with certain kinds of scrolling as I sometimes use the cursor as a temporary bookmark...

dstein64 commented 7 months ago

As of e1e3237e22d833e814fa8253574c070832456e65, cursor position is retained while dragging.

I tried to implement cursor positioning in a manner similar to what happens with mouse wheel scrolling, but I was unable to get the updated cursor position to show during dragging (after dragging was not an issue).

There are a few scenarios where the cursor position is not retained. For example, if the line that the cursor is on after dragging is too short, the cursor may shift to the left. If the cursor starts towards the top of the window at the beginning of a buffer, the cursor may shift down after dragging, to accommodate scrolloff.

Additionally, there is an issue when the cursor ends on a line with concealed text from syntax highlighting, resulting in the cursor being incorrectly positioned left of where it should be (this can be seen on :help buffers, although the presence of tabs in those buffers can mask the problem). I believe the calculations the plugin performs are taking place prior to the concealcursor application. I don't know a way to properly adjust for that.

I've found that the cursor position is shown while dragging if there are not wrapped lines, but the cursor temporarily moves (for the duration of dragging) towards the bottom left of the window if there are wrapped lines.

dstein64 commented 7 months ago

"Additionally, there is an issue when the cursor ends on a line with concealed text from syntax highlighting, resulting in the cursor being incorrectly positioned left of where it should be (this can be seen on :help buffers, although the presence of tabs in those buffers can mask the problem)."

I've fixed the problematic behavior that arose with concealed text.

The pending issue is that the cursor moves to the bottom left of the screen while dragging the scrollbar when lines are wrapped. I've opened #128 for that.

I'll close this Issue for now. @MikeLemo1, please let me know if the recent updates don't resolve the matter for you (excluding the aforementioned wrap problem that still exists, which has a new Issue).