summaryrefslogtreecommitdiffstats
path: root/src/config.rs
diff options
context:
space:
mode:
authorThomas Otto <th1000s@posteo.net>2023-05-31 19:17:18 +0200
committerGitHub <noreply@github.com>2023-05-31 13:17:18 -0400
commit139cdb9656292edba917fd6addc0a7960cf60342 (patch)
treed598b6663e03ebd5f54d2198b00df4d00d25c893 /src/config.rs
parent65418aaa3bc064dc7ce34e6d2f231b96a5c6acb9 (diff)
Misc tab refactoring (#1424)
* Move tabs logic into utils * Re-use buffer returned by tabs::expand * Add TabCfg to configure tabs Use the String from this config for the tab replacement. This avoids creating a new String for each processed line. * Avoid unicode segmentation for each line just to remove a prefix In some code paths no prefix is removed, and in almost all other cases the prefix is just ascii. This simplifies a lot of calls. * Set default tab with to 8 Editors like vim, emacs, nano and most terminal emulators set this value as the default tab display width.
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/config.rs b/src/config.rs
index 10ab0eca..3d411ea4 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -120,7 +120,7 @@ pub struct Config {
pub syntax_dummy_theme: SyntaxTheme,
pub syntax_set: SyntaxSet,
pub syntax_theme: Option<SyntaxTheme>,
- pub tab_width: usize,
+ pub tab_cfg: utils::tabs::TabCfg,
pub tokenization_regex: Regex,
pub true_color: bool,
pub truncation_symbol: String,
@@ -357,7 +357,7 @@ impl From<cli::Opt> for Config {
syntax_dummy_theme: SyntaxTheme::default(),
syntax_set: opt.computed.syntax_set,
syntax_theme: opt.computed.syntax_theme,
- tab_width: opt.tab_width,
+ tab_cfg: utils::tabs::TabCfg::new(opt.tab_width),
tokenization_regex,
true_color: opt.computed.true_color,
truncation_symbol: format!("{}→{}", ansi::ANSI_SGR_REVERSE, ansi::ANSI_SGR_RESET),