mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-15 16:53:25 +00:00
cli: rename ColorWordsOptions to ColorWordsDiffOptions
I'm going to add an options struct for git diff, but GitOptions, UnifiedOptions, StatOptions, etc. sound odd.
This commit is contained in:
parent
383cca4c4d
commit
df40a09a5d
2 changed files with 10 additions and 10 deletions
|
@ -1504,7 +1504,7 @@ fn builtin_tree_diff_methods<'repo>() -> CommitTemplateBuildMethodFnMap<'repo, T
|
||||||
let template = (self_property, context_property)
|
let template = (self_property, context_property)
|
||||||
.map(move |(diff, context)| {
|
.map(move |(diff, context)| {
|
||||||
// TODO: load defaults from UserSettings?
|
// TODO: load defaults from UserSettings?
|
||||||
let options = diff_util::ColorWordsOptions {
|
let options = diff_util::ColorWordsDiffOptions {
|
||||||
context: context.unwrap_or(diff_util::DEFAULT_CONTEXT_LINES),
|
context: context.unwrap_or(diff_util::DEFAULT_CONTEXT_LINES),
|
||||||
max_inline_alternation: Some(3),
|
max_inline_alternation: Some(3),
|
||||||
};
|
};
|
||||||
|
|
|
@ -123,7 +123,7 @@ pub enum DiffFormat {
|
||||||
Types,
|
Types,
|
||||||
NameOnly,
|
NameOnly,
|
||||||
Git { context: usize },
|
Git { context: usize },
|
||||||
ColorWords(Box<ColorWordsOptions>),
|
ColorWords(Box<ColorWordsDiffOptions>),
|
||||||
Tool(Box<ExternalMergeTool>),
|
Tool(Box<ExternalMergeTool>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ fn diff_formats_from_args(
|
||||||
formats.push(DiffFormat::Git { context });
|
formats.push(DiffFormat::Git { context });
|
||||||
}
|
}
|
||||||
if args.color_words {
|
if args.color_words {
|
||||||
let options = ColorWordsOptions::from_settings_and_args(settings, args)?;
|
let options = ColorWordsDiffOptions::from_settings_and_args(settings, args)?;
|
||||||
formats.push(DiffFormat::ColorWords(Box::new(options)));
|
formats.push(DiffFormat::ColorWords(Box::new(options)));
|
||||||
}
|
}
|
||||||
if args.stat {
|
if args.stat {
|
||||||
|
@ -219,7 +219,7 @@ fn default_diff_format(
|
||||||
context: args.context.unwrap_or(DEFAULT_CONTEXT_LINES),
|
context: args.context.unwrap_or(DEFAULT_CONTEXT_LINES),
|
||||||
}),
|
}),
|
||||||
"color-words" => {
|
"color-words" => {
|
||||||
let options = ColorWordsOptions::from_settings_and_args(settings, args)?;
|
let options = ColorWordsDiffOptions::from_settings_and_args(settings, args)?;
|
||||||
Ok(DiffFormat::ColorWords(Box::new(options)))
|
Ok(DiffFormat::ColorWords(Box::new(options)))
|
||||||
}
|
}
|
||||||
"stat" => Ok(DiffFormat::Stat),
|
"stat" => Ok(DiffFormat::Stat),
|
||||||
|
@ -426,14 +426,14 @@ pub fn get_copy_records<'a>(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
pub struct ColorWordsOptions {
|
pub struct ColorWordsDiffOptions {
|
||||||
/// Number of context lines to show.
|
/// Number of context lines to show.
|
||||||
pub context: usize,
|
pub context: usize,
|
||||||
/// Maximum number of removed/added word alternation to inline.
|
/// Maximum number of removed/added word alternation to inline.
|
||||||
pub max_inline_alternation: Option<usize>,
|
pub max_inline_alternation: Option<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ColorWordsOptions {
|
impl ColorWordsDiffOptions {
|
||||||
fn from_settings_and_args(
|
fn from_settings_and_args(
|
||||||
settings: &UserSettings,
|
settings: &UserSettings,
|
||||||
args: &DiffFormatArgs,
|
args: &DiffFormatArgs,
|
||||||
|
@ -448,7 +448,7 @@ impl ColorWordsOptions {
|
||||||
})?),
|
})?),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Ok(ColorWordsOptions {
|
Ok(ColorWordsDiffOptions {
|
||||||
context: args.context.unwrap_or(DEFAULT_CONTEXT_LINES),
|
context: args.context.unwrap_or(DEFAULT_CONTEXT_LINES),
|
||||||
max_inline_alternation,
|
max_inline_alternation,
|
||||||
})
|
})
|
||||||
|
@ -459,7 +459,7 @@ fn show_color_words_diff_hunks(
|
||||||
formatter: &mut dyn Formatter,
|
formatter: &mut dyn Formatter,
|
||||||
left: &[u8],
|
left: &[u8],
|
||||||
right: &[u8],
|
right: &[u8],
|
||||||
options: &ColorWordsOptions,
|
options: &ColorWordsDiffOptions,
|
||||||
) -> io::Result<()> {
|
) -> io::Result<()> {
|
||||||
let line_diff = Diff::by_line([left, right]);
|
let line_diff = Diff::by_line([left, right]);
|
||||||
let mut line_number = DiffLineNumber { left: 1, right: 1 };
|
let mut line_number = DiffLineNumber { left: 1, right: 1 };
|
||||||
|
@ -539,7 +539,7 @@ fn show_color_words_diff_lines(
|
||||||
formatter: &mut dyn Formatter,
|
formatter: &mut dyn Formatter,
|
||||||
contents: &[&BStr],
|
contents: &[&BStr],
|
||||||
mut line_number: DiffLineNumber,
|
mut line_number: DiffLineNumber,
|
||||||
options: &ColorWordsOptions,
|
options: &ColorWordsDiffOptions,
|
||||||
) -> io::Result<DiffLineNumber> {
|
) -> io::Result<DiffLineNumber> {
|
||||||
let word_diff_hunks = Diff::by_word(contents).hunks().collect_vec();
|
let word_diff_hunks = Diff::by_word(contents).hunks().collect_vec();
|
||||||
let can_inline = match options.max_inline_alternation {
|
let can_inline = match options.max_inline_alternation {
|
||||||
|
@ -788,7 +788,7 @@ pub fn show_color_words_diff(
|
||||||
store: &Store,
|
store: &Store,
|
||||||
tree_diff: BoxStream<CopiesTreeDiffEntry>,
|
tree_diff: BoxStream<CopiesTreeDiffEntry>,
|
||||||
path_converter: &RepoPathUiConverter,
|
path_converter: &RepoPathUiConverter,
|
||||||
options: &ColorWordsOptions,
|
options: &ColorWordsDiffOptions,
|
||||||
) -> Result<(), DiffRenderError> {
|
) -> Result<(), DiffRenderError> {
|
||||||
let mut diff_stream = materialized_diff_stream(store, tree_diff);
|
let mut diff_stream = materialized_diff_stream(store, tree_diff);
|
||||||
async {
|
async {
|
||||||
|
|
Loading…
Reference in a new issue