forked from mirrors/jj
cli: use ui.reset() to process --config-toml arguments
This should also fix handling of --config-toml 'colors...'. Before, the color table wouldn't be updated without mode change.
This commit is contained in:
parent
fa68a21bd1
commit
1b45c5fe8e
3 changed files with 2 additions and 19 deletions
|
@ -1558,7 +1558,8 @@ fn handle_early_args(
|
|||
ui.set_pagination(crate::ui::PaginationChoice::No);
|
||||
}
|
||||
if !args.config_toml.is_empty() {
|
||||
ui.extra_toml_settings(&args.config_toml)?;
|
||||
let settings = ui.settings().with_toml_strings(&args.config_toml)?;
|
||||
ui.reset(settings);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -89,10 +89,6 @@ impl FormatterFactory {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_color(&self) -> bool {
|
||||
matches!(&self.kind, FormatterFactoryKind::Color { .. })
|
||||
}
|
||||
}
|
||||
|
||||
pub struct PlainTextFormatter<W> {
|
||||
|
|
14
src/ui.rs
14
src/ui.rs
|
@ -146,14 +146,6 @@ impl Ui {
|
|||
self.settings = settings;
|
||||
}
|
||||
|
||||
/// Reconfigures the underlying outputs with the new color choice.
|
||||
pub fn reset_color(&mut self, choice: ColorChoice) {
|
||||
self.color = use_color(choice);
|
||||
if self.formatter_factory.is_color() != self.color {
|
||||
self.formatter_factory = FormatterFactory::prepare(&self.settings, self.color);
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets the pagination value.
|
||||
pub fn set_pagination(&mut self, choice: PaginationChoice) {
|
||||
self.paginate = choice;
|
||||
|
@ -193,12 +185,6 @@ impl Ui {
|
|||
&self.settings
|
||||
}
|
||||
|
||||
pub fn extra_toml_settings(&mut self, toml_strs: &[String]) -> Result<(), config::ConfigError> {
|
||||
self.settings = self.settings.with_toml_strings(toml_strs)?;
|
||||
self.reset_color(color_setting(&self.settings));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn new_formatter<'output, W: Write + 'output>(
|
||||
&self,
|
||||
output: W,
|
||||
|
|
Loading…
Reference in a new issue