From 827b7549cb2cf130e3c685047d10b7e478284c9c Mon Sep 17 00:00:00 2001 From: Ed Page Date: Thu, 22 Aug 2024 10:03:26 -0500 Subject: [PATCH] fix(config): Don't overwrite locale and tokenizer config This was broken in #882 --- crates/typos-cli/src/policy.rs | 11 +++++++---- crates/typos-cli/tests/cmd/en-us.toml | 10 +++++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/crates/typos-cli/src/policy.rs b/crates/typos-cli/src/policy.rs index daf4cc85d..e7b83c1ec 100644 --- a/crates/typos-cli/src/policy.rs +++ b/crates/typos-cli/src/policy.rs @@ -227,13 +227,16 @@ impl<'s> ConfigEngine<'s> { let check_filename = engine.check_filename(); let check_file = engine.check_file(); let crate::config::EngineConfig { - tokenizer: mut tokenizer_config, - dict: mut dict_config, + tokenizer: tokenizer_user_config, + dict: dict_user_config, extend_ignore_re, .. } = engine; - tokenizer_config.update(&crate::config::TokenizerConfig::from_defaults()); - dict_config.update(&crate::config::DictConfig::from_defaults()); + + let mut tokenizer_config = crate::config::TokenizerConfig::from_defaults(); + tokenizer_config.update(&tokenizer_user_config); + let mut dict_config = crate::config::DictConfig::from_defaults(); + dict_config.update(&dict_user_config); if !tokenizer_config.ignore_hex() { log::warn!("`ignore-hex` is deprecated"); diff --git a/crates/typos-cli/tests/cmd/en-us.toml b/crates/typos-cli/tests/cmd/en-us.toml index 324f41d7f..4c5f63978 100644 --- a/crates/typos-cli/tests/cmd/en-us.toml +++ b/crates/typos-cli/tests/cmd/en-us.toml @@ -1,4 +1,12 @@ bin.name = "typos" stdin = "" -stdout = "" +stdout = """ +error: `colour` should be `color` + --> ./README.md:1:10 + | +1 | color or colour + | ^^^^^^ + | +""" stderr = "" +status.code = 2