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

Change how goto_beginning, goto_top handle scrolling #1073

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

7415963987456321
Copy link

Similar to the issue in #1039 but not quite the same since this PR only affects the commands.
Currently when navigating to the top/bottom of the page using keyboard or entering command, sioyek will scroll past the page edge, I found this bothersome and I see no benefit to scrolling past the page like that.

  • This changes the way sioyek handles going to the top and bottom of the page with gg and G, or goto_end and goto_beginning commands.
    • Scrolling to the top with gg/ goto_beginning will now stop the page absolutely at the top of the screen
    • Similarly when scrolling to the bottom with G, goto_end, the page will not scroll past the bottom edge
  • Changed the way numer repeats offsets the page,
    • Ex. 0gg is equivalent to gg, 1gg is one page from the top i.e. page 2, 2gg is page 3 ... e.t.c
    • Same for scrolling to bottom, 0G is same as G, 1G is next to last page e.t.c
  • Fix the 'begining' typo in some functions

Should clarify the code, makes it easier to find if it is correctly
spelled
This implements goto_beginning() and simplifies the goto_end() function
@7415963987456321
Copy link
Author

Did not occur to me to check the development branch, at a quick glance it seems like these changes have not yet been implemented on there, will rebase these changes onto developer and test further.

@HakonHarnes
Copy link

Hope this PR gets merged. I also find it annoying how the gg the G commands scroll past the edge of the page.

However, I don't think it's a good idea to change how number repeats offsets the page. Having e.g. 2gg navigate to page 3 doesn't make sense. In my head 2gg translates to "go to page 2", and should go to page 2, not 3. The same principle is true in vim; 10gg will navigate to line 10, not line 11.

@7415963987456321
Copy link
Author

However, I don't think it's a good idea to change how number repeats offsets the page. Having e.g. 2gg navigate to page 3 doesn't make sense. In my head 2gg translates to "go to page 2", and should go to page 2, not 3. The same principle is true in vim; 10gg will navigate to line 10, not line 11.

Good point, don't generally use that feature of vim, or sioyek for that matter, just had a look at how vim is handling this, and I agree that this PR should behave the same way. Will revisit this at a later date when I have the time.

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 this pull request may close these issues.

None yet

2 participants