aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui
diff options
context:
space:
mode:
authorA-Walrus2022-08-21 04:54:02 +0000
committerGitHub2022-08-21 04:54:02 +0000
commited74e6d5d405dd37e067c5fd41e2ae908da22a3c (patch)
tree4a3738cc1a3538f2d13cb3f54d7a277b578923dc /helix-term/src/ui
parente61c0b461cc5906d8db8ccffe1c0d3530a83c5a5 (diff)
Switch to `tabpad` configuration option (#3458)
Virtual whitespace tabs are created from the `tab` character padded with `tabpad` up to the tab width.
Diffstat (limited to 'helix-term/src/ui')
-rw-r--r--helix-term/src/ui/editor.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index 401d284e..438d1412 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -390,19 +390,23 @@ impl EditorView {
// of times than it is to always call Rope::slice/get_slice (it will internally always hit RSEnum::Light).
let text = doc.text().slice(..);
+ let characters = &whitespace.characters;
+
let mut spans = Vec::new();
let mut visual_x = 0u16;
let mut line = 0u16;
let tab_width = doc.tab_width();
let tab = if whitespace.render.tab() == WhitespaceRenderValue::All {
- (1..tab_width).fold(whitespace.characters.tab.to_string(), |s, _| s + " ")
+ std::iter::once(characters.tab)
+ .chain(std::iter::repeat(characters.tabpad).take(tab_width - 1))
+ .collect()
} else {
" ".repeat(tab_width)
};
- let space = whitespace.characters.space.to_string();
- let nbsp = whitespace.characters.nbsp.to_string();
+ let space = characters.space.to_string();
+ let nbsp = characters.nbsp.to_string();
let newline = if whitespace.render.newline() == WhitespaceRenderValue::All {
- whitespace.characters.newline.to_string()
+ characters.newline.to_string()
} else {
" ".to_string()
};