Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

* incorrectly restores view due to wrapped lines #29

Open
nkouevda opened this issue Sep 6, 2023 · 0 comments · May be fixed by #30
Open

* incorrectly restores view due to wrapped lines #29

nkouevda opened this issue Sep 6, 2023 · 0 comments · May be fixed by #30

Comments

@nkouevda
Copy link

nkouevda commented Sep 6, 2023

Problem

If e.g. 1) the first line in the window is wrapped, 2) the cursor is on any line below that, and 3) * would cause the view to move down (i.e. the next match is not yet visible), then winline() - s:winline will usually compute an incorrect sdiff, and we will <C-y> more times than necessary, shifting the view up by at least 1 line (unless we were already at the beginning of the buffer, or there are some other edge cases).

Possible solution

I believe using winsaveview()['topline'] instead of winline() avoids this discrepancy between buffer lines and screen lines.

I'll put up a PR with that approach, but 1) I'm not sure if there's a simpler way to get topline (maybe some function I overlooked?), and 2) although I've tested this with all edge cases that I'm aware of, I can't be sure that this entirely fixes this issue, or that it doesn't break anything else.

nkouevda added a commit to nkouevda/vim-slash that referenced this issue Sep 6, 2023
@nkouevda nkouevda linked a pull request Sep 6, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant