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

Keep viewport when switching files #417

Open
lars-vc opened this issue Dec 13, 2023 · 8 comments
Open

Keep viewport when switching files #417

lars-vc opened this issue Dec 13, 2023 · 8 comments

Comments

@lars-vc
Copy link

lars-vc commented Dec 13, 2023

What issue are you having that you need harpoon to solve?
I would like to keep the viewport after switching files, currently the line is always centered on the screen.
Keeping the viewport would only be necessary in the same session (after nvim reboot this is not required)

Why doesn't the current config help?
No options are provided for this

What proposed api changes are you suggesting?
Vim already has some options to keep the viewport with winsaveview() and winrestview(view), these could be used to save the viewport.

@ThePrimeagen
Copy link
Owner

you want the same position the viewport was in before you left the file? is that what you are asking?

@lars-vc
Copy link
Author

lars-vc commented Dec 15, 2023

Yes, when using harpoon I like to switch between files quickly, to for instance just take a glance at some code and hop back. When this centers the line every time, this gets disorienting.
Example: I am working here
image

Then quickly check another file with harpoon keybind and go back with harpoon keybind and now the line is centered
image

@lpanebr
Copy link

lpanebr commented Dec 16, 2023

I also would like that.

@ThePrimeagen
Copy link
Owner

Okay, it seems like an okay feature. I don't really use it nor notices, so if someone would like to take a swing at saving the additional information required in the list items, context and using that on select I'd be just fine merging it in

@lars-vc
Copy link
Author

lars-vc commented Dec 18, 2023

Okay, I tried some stuff but got a lil confused, so here

you save where you are at in the file when leaving a buffer correct? But when testing, it seems this code is never triggered (the logger line right before doesn't show up).
So is this not working? Or am I doing something wrong.

@lars-vc
Copy link
Author

lars-vc commented Mar 5, 2024

This wiki is related to the problem viewport problem @lpanebr . Might just use this for consistency everywhere
https://vim.fandom.com/wiki/Avoid_scrolling_when_switch_buffers

@lpanebr
Copy link

lpanebr commented Mar 5, 2024

@lars-vc Thank you! This is just AWESOME and works like magic! ❤🎉

This wiki is related to the problem viewport problem @lpanebr . Might just use this for consistency everywhere https://vim.fandom.com/wiki/Avoid_scrolling_when_switch_buffers

@ThePrimeagen
Copy link
Owner

I am back, I'll review this today and merge/give feedback

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

No branches or pull requests

3 participants