-
-
Couldn't load subscription status.
- Fork 3.1k
Redone #4189, working preview scrolling #11441
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
base: master
Are you sure you want to change the base?
Conversation
|
Current keybindings:
|
ecd415f to
a69ea1d
Compare
|
Hi! Thank you for your help. I fixed my mistakes, and now all should work well. My only concern is about keybinding alt-PageUp, because as mentioned before:
In my case alt-PageDown works pretty fine, but alt-PageUp doesn't. But as mentioned above it might be just a limitation on my platform. |
|
I've tried it, works very well, very welcomed addition ! I hope it will be merged soon :-) |
I am not a fan of using the |
|
Hi! Thank u for using helix based on my PR. If u find more bugs I will be happy to fix them :) |
|
@David-Else Using just PageUp or PageDown seems like nice idea. |
|
Are there any blockers before this can be merged? |
|
I can consistently reproduce a panic when using this. (disclaimer, I do have other branches too merged into my fork too, but I can only reproduce this issue when this PR is included):
Can you try to reproduce? It may be possible it is just my unique setup, but like I said, I've only seen this when using this PR. |
c61eea4 to
40d9547
Compare
|
Hi! Thank you for pointing out the error. This panic was indeed related to this PR. I missed it during testing - perhaps I didn't run enough tests - so I am sorry for that oversight. Together with @qiu-x, we have fixed the issue. We switched to using offset_anchor instead of offset_vertical_offset to move the preview, and this resolved the problem. We ran several tests and did not encounter any more panics. I hope everything works fine now. I look forward to your feedback! Please let me know if everything is working as expected Thank you once again! |
|
this PR also closes #1614 |
|
Are the kebindings configurable? |
|
Currently not, but I will add this idea to my to-do list, and implement it.
Now as I am looking at |
|
What is stopping from this being merged to master? |
`patchy` is a tool which makes it easy to declaratively manage personal forks by automatically merging pull requests. Check it out here: https://github.com/NikitaRevenco/patchy
`patchy` is a tool which makes it easy to declaratively manage personal forks by automatically merging pull requests. Check it out here: https://github.com/NikitaRevenco/patchy
|
Why aren't we getting this merged? |
eda5aa1 to
16b0db2
Compare
|
This would be a very welcome feature as a new user. The current behavior isn't what I would have expected. Looking forward to seeing this merged -- thanks for all the hard work! |
|
@GNUSheep Can you rebase your branch ? It has conflicts now ><' |
Co-authored-by: GNUSheep <zydekpiotr26@gmail.com> Co-authored-by: Manos Mertzianis <manosmertzianis@gmail.com>
16b0db2 to
2a1d44f
Compare
|
@EmrysMyrddin |
|
Thank you ! You're awesome ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like this doesn't work well with soft-wrap enabled. Setting editor.soft-wrap.enable to true also enables soft-wrap in the picker and when a file has long lines I can't get to the bottom in the preview with A-d
| key!(PageDown) | ctrl!('d') => { | ||
| key!(PageDown) | ctrl!('d') if !self.show_preview => { | ||
| self.page_down(); | ||
| } | ||
| key!(PageUp) | ctrl!('u') => { | ||
| key!(PageUp) | ctrl!('u') if !self.show_preview => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will leave C-u/C-d unbound when showing the preview. Instead we can separate these out so that C-u/C-d always does page_up/page_down and gate key!(PageUp)/key!(PageDown) on self.show_preview
| const fn div_ceil(a: usize, b: usize) -> usize { | ||
| (a + b - 1) / b | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be written with div_ceil from std now, also see
helix/helix-term/src/ui/menu.rs
Line 355 in d1750a7
| let scroll_height = win_height.pow(2).div_ceil(len).min(win_height); |
It stabilized somewhat recently in 1.73 and we had to define it ourselves before then
| match move_direction { | ||
| Direction::Backward => match current_scroll_direction { | ||
| Direction::Backward => { | ||
| self.preview_scroll_offset.1 = current_scroll_offset.saturating_add(amount); | ||
| } | ||
| Direction::Forward => { | ||
| if let Some(change) = current_scroll_offset.checked_sub(amount) { | ||
| self.preview_scroll_offset.1 = change; | ||
| } else { | ||
| self.preview_scroll_offset = ( | ||
| Direction::Backward, | ||
| amount.saturating_sub(current_scroll_offset), | ||
| ); | ||
| } | ||
| } | ||
| }, | ||
| Direction::Forward => match current_scroll_direction { | ||
| Direction::Backward => { | ||
| if let Some(change) = current_scroll_offset.checked_sub(amount) { | ||
| self.preview_scroll_offset.1 = change; | ||
| } else { | ||
| self.preview_scroll_offset = ( | ||
| Direction::Forward, | ||
| amount.saturating_sub(current_scroll_offset), | ||
| ); | ||
| } | ||
| } | ||
| Direction::Forward => { | ||
| self.preview_scroll_offset.1 = current_scroll_offset.saturating_add(amount); | ||
| } | ||
| }, | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be simplified a bit since the branches are nearly duplicates
| match move_direction { | |
| Direction::Backward => match current_scroll_direction { | |
| Direction::Backward => { | |
| self.preview_scroll_offset.1 = current_scroll_offset.saturating_add(amount); | |
| } | |
| Direction::Forward => { | |
| if let Some(change) = current_scroll_offset.checked_sub(amount) { | |
| self.preview_scroll_offset.1 = change; | |
| } else { | |
| self.preview_scroll_offset = ( | |
| Direction::Backward, | |
| amount.saturating_sub(current_scroll_offset), | |
| ); | |
| } | |
| } | |
| }, | |
| Direction::Forward => match current_scroll_direction { | |
| Direction::Backward => { | |
| if let Some(change) = current_scroll_offset.checked_sub(amount) { | |
| self.preview_scroll_offset.1 = change; | |
| } else { | |
| self.preview_scroll_offset = ( | |
| Direction::Forward, | |
| amount.saturating_sub(current_scroll_offset), | |
| ); | |
| } | |
| } | |
| Direction::Forward => { | |
| self.preview_scroll_offset.1 = current_scroll_offset.saturating_add(amount); | |
| } | |
| }, | |
| }; | |
| if move_direction == current_scroll_direction { | |
| self.preview_scroll_offset.1 = current_scroll_offset.saturating_add(amount); | |
| } else if let Some(change) = current_scroll_offset.checked_sub(amount) { | |
| self.preview_scroll_offset.1 = change; | |
| } else { | |
| self.preview_scroll_offset = | |
| (move_direction, amount.saturating_sub(current_scroll_offset)); | |
| } |
|
Hi @the-mikedavis |





Finally redone preview scrolling on current master. Works pretty fine.
I used code from: @Manosmer, and make it work with current version of helix.
Connects #1614