diff options
author | Dan Davison <dandavison7@gmail.com> | 2021-02-12 14:03:45 -0500 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2021-02-17 10:23:03 -0500 |
commit | 97c58c4586508bdb84cc68873ac1294309a7268f (patch) | |
tree | c8a672502a94eb73c93150c787a314d081a7ca93 /src/paint.rs | |
parent | 64c93a7f8a4babe7ef794ed053cb06baef1dcd3b (diff) |
Allow user to specify tab replacement string522-tab-string
Fixes #522
Diffstat (limited to 'src/paint.rs')
-rw-r--r-- | src/paint.rs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/paint.rs b/src/paint.rs index bf85fb13..415726a1 100644 --- a/src/paint.rs +++ b/src/paint.rs @@ -114,10 +114,15 @@ impl<'a> Painter<'a> { where I: Iterator<Item = &'b str>, { - if self.config.tab_width > 0 { - let tab_replacement = " ".repeat(self.config.tab_width); - line.map(|s| if s == "\t" { &tab_replacement } else { s }) - .collect::<String>() + if !self.config.tab_string.is_empty() { + line.map(|s| { + if s == "\t" { + &self.config.tab_string + } else { + s + } + }) + .collect::<String>() } else { line.collect::<String>() } |