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

horizontal and vertical scrolloff #12344

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Wiener234
Copy link

Splits scrolloff option into scrolloff.horizontal and scrolloff.vertical.

This allows to have the line with the cursor centered while not centering also the column with the cursor.

screenshot-2024-12-26-12-20-47

On the left the scrolloff is set to 999 and i moved to the right of the line. On the right scrolloff.vertical is set to 999 and scrolloff.horizontal is set to 5 and i scrolled to the right of the line.

The right side gives you the option to have the line with the cursor centered while still not centering the column, allowing to edit files in split view with a line length of 80 without loosing the beginning of the line.

Nils and others added 6 commits December 14, 2024 20:43
just make horizontal scrolloff always 5, because in dont know how to
add new settings
adds struct for scrolloff with horizontal and vertical option
lets you adjust the scrolloff for horizontal and vertical independently
adds struct for scrolloff with horizontal and vertical option
lets you adjust the scrolloff for horizontal and vertical independently
adding section for scrolloff explaining the suboptions for vertical and
horizontal
@nik-rev
Copy link
Contributor

nik-rev commented Dec 26, 2024

nifty feature, thank you!

Comment on lines +967 to +968
// scrolloff: 5,
// scrolloff_horizontal: 5,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// scrolloff: 5,
// scrolloff_horizontal: 5,

I'd remove this because you just need to go to the default implementation of ScrolloffConfig to see the values.
Also this could potential become "dangerous" if you update the default values because you have to remember to update those comments as well.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are completely right. I forgot to remove these comments. They were there when I tested if it would even work.

.horizontal
.min(viewport.width.saturating_sub(1) as usize / 2),
scrolloff.horizontal.min(viewport.width as usize / 2),
// 5, 5,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I ask what those 5, 5 should represent?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were are also from testing. My mistake I just hard coded the values until I managed to implement the config function.

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case", default, deny_unknown_fields)]
pub struct Config {
/// Padding to keep between the edge of the screen and the cursor when scrolling. Defaults to 5.
pub scrolloff: usize,
// pub scrolloff_horizontal: usize,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... did you forgot to remove the old entry here?

peepoThonk

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.

3 participants