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

Expose line-buffer-size as a new option #429

Merged
merged 2 commits into from
Dec 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,15 @@ pub struct Opt {
#[structopt(long = "whitespace-error-style", default_value = "auto auto")]
pub whitespace_error_style: String,

#[structopt(long = "line-buffer-size", default_value = "32")]
/// Size of internal line buffer. Delta compares the added and removed versions of nearby lines
/// in order to detect and highlight changes at the level of individual words/tokens.
/// Therefore, nearby lines must be buffered internally before they are painted and emitted.
/// Increasing this value might improve highlighting of some large diff hunks. However, setting
/// this to a high value will adversely affect delta's performance when entire files are
/// added/removed.
pub line_buffer_size: usize,

#[structopt(long = "minus-color")]
/// Deprecated: use --minus-style='normal my_background_color'.
pub deprecated_minus_background_color: Option<String>,
Expand Down
4 changes: 2 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub struct Config {
pub line_numbers_right_style: Style,
pub line_numbers_show_first_line_number: bool,
pub line_numbers_zero_style: Style,
pub max_buffered_lines: usize,
pub line_buffer_size: usize,
pub max_line_distance: f64,
pub max_line_distance_for_naively_paired_lines: f64,
pub max_line_length: usize,
Expand Down Expand Up @@ -173,7 +173,7 @@ impl From<cli::Opt> for Config {
line_numbers_show_first_line_number: (opt.computed.line_numbers_mode
== cli::LineNumbersMode::First),
line_numbers_zero_style,
max_buffered_lines: 32,
line_buffer_size: opt.line_buffer_size,
max_line_distance: opt.max_line_distance,
max_line_distance_for_naively_paired_lines,
max_line_length: opt.max_line_length,
Expand Down
4 changes: 2 additions & 2 deletions src/delta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,8 @@ fn handle_hunk_line(
// Don't let the line buffers become arbitrarily large -- if we
// were to allow that, then for a large deleted/added file we
// would process the entire file before painting anything.
if painter.minus_lines.len() > config.max_buffered_lines
|| painter.plus_lines.len() > config.max_buffered_lines
if painter.minus_lines.len() > config.line_buffer_size
|| painter.plus_lines.len() > config.line_buffer_size
{
painter.paint_buffered_minus_and_plus_lines();
}
Expand Down
1 change: 1 addition & 0 deletions src/options/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ pub fn set_options(
hyperlinks_file_link_format,
inspect_raw_lines,
keep_plus_minus_markers,
line_buffer_size,
max_line_distance,
max_line_length,
// Hack: minus-style must come before minus-*emph-style because the latter default
Expand Down