-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
base: master
Are you sure you want to change the base?
Conversation
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
nifty feature, thank you! |
// scrolloff: 5, | ||
// scrolloff_horizontal: 5, |
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.
// 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.
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.
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, |
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.
May I ask what those 5, 5
should represent?
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.
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, |
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.
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.
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.