Skip to content

Change how goto_beginning, goto_top handle scrolling#1073

Open
7415963987456321 wants to merge 3 commits intoahrm:mainfrom
7415963987456321:top_of_page
Open

Change how goto_beginning, goto_top handle scrolling#1073
7415963987456321 wants to merge 3 commits intoahrm:mainfrom
7415963987456321:top_of_page

Conversation

@7415963987456321
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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.

2 participants