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

add paging mode option #109

Merged
merged 4 commits into from
Mar 1, 2020
Merged

Conversation

jesseduffield
Copy link
Contributor

fixes #108

This is my first ever PR in rust, hopefully the first of many!

The use case here is to allow me to use delta in lazygit without having to deal with less getting in the way

Copy link
Owner

@dandavison dandavison left a comment

Choose a reason for hiding this comment

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

Awesome, thanks very much for doing this! I'm going to have to check out lazygit and what it looks like to have delta running in it.

Since github allows it, I went ahead and pushed a couple of small tweaks to your branch.

There are a couple of issues with delta that I noticed in the course of this, but none of them need concern you... Firstly, it seems like the behavior you wanted should have been achievable by setting the two relevant environment variables to empty string, but that's not true currently:

python -c "for i in range(999999): print(i)" | BAT_PAGER= PAGER= delta

Secondly, delta should only spawn the pager when its output is an interactive terminal (as opposed to a pipe or file redirect). This is how bat behaves, but that's also not true for delta currently. I've left the "auto" option vaguely documented so that it can acquire that behavior in a future PR.

/// default pager is `less`: this can be altered by setting the environment variables BAT_PAGER
/// or PAGER (BAT_PAGER has priority).
#[structopt(long = "paging", default_value = "auto")]
pub paging_mode: String,
Copy link
Owner

Choose a reason for hiding this comment

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

Since delta is in some ways similar to bat, I've made it a design guideline to be exactly the same as bat wherever it makes sense. bat has basically exactly the option that you're adding, so I've pushed commits to your PR making the interface identical. Here's a section from bat --help for reference.

image

Copy link
Owner

Choose a reason for hiding this comment

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

Sorry I should be totally explicit here, since lazy git is going to pass this option: I have changed the name of the option in your PR so that it will now be --paging=never.

process::exit(1);
}
};

Copy link
Owner

Choose a reason for hiding this comment

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

I made a small change here to demand that if the user supplies a value, it is valid.

@@ -624,6 +624,7 @@ mod tests {
hunk_style: cli::SectionStyle::Box,
hunk_color: "blue".to_string(),
width: Some("variable".to_string()),
paging_mode: "auto".to_string(),
Copy link
Owner

Choose a reason for hiding this comment

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

I had to add an entry here to make delta's tests pass.

@dandavison dandavison merged commit 655af49 into dandavison:master Mar 1, 2020
@jesseduffield
Copy link
Contributor Author

Thanks for the quick response :)

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.

Add flag to disable 'less' behaviour
2 participants