on master help sign in
Switch to `tabpad` configuration option (#3458)
ed74e6dA-Walrus
book/src/configuration.md+2−1
@@ -192,7 +192,7 @@ Options for rendering whitespace with visible characters. Use `:set whitespace.r
192| Key | Description | Default |
192| Key | Description | Default |
193|-----|-------------|---------|
193|-----|-------------|---------|
194| `render` | Whether to render whitespace. May either be `"all"` or `"none"`, or a table with sub-keys `space`, `tab`, and `newline`. | `"none"` |
194| `render` | Whether to render whitespace. May either be `"all"` or `"none"`, or a table with sub-keys `space`, `tab`, and `newline`. | `"none"` |
195−| `characters` | Literal characters to use when rendering whitespace. Sub-keys may be any of `tab`, `space`, `nbsp` or `newline` | See example below |
195+| `characters` | Literal characters to use when rendering whitespace. Sub-keys may be any of `tab`, `space`, `nbsp`, `newline` or `tabpad` | See example below |
196
196
197Example
197Example
198
198
@@ -210,6 +210,7 @@ space = "·"
210nbsp = "⍽"
210nbsp = "⍽"
211tab = "→"
211tab = "→"
212newline = "⏎"
212newline = "⏎"
213+tabpad = "·" # Tabs will look like "→···" (depending on tab width)
213```
214```
214
215
215### `[editor.indent-guides]` Section
216### `[editor.indent-guides]` Section
helix-term/src/ui/editor.rs+8−4
@@ -390,19 +390,23 @@ impl EditorView {
390 // of times than it is to always call Rope::slice/get_slice (it will internally always hit RSEnum::Light).
390 // of times than it is to always call Rope::slice/get_slice (it will internally always hit RSEnum::Light).
391 let text = doc.text().slice(..);
391 let text = doc.text().slice(..);
392
392
393+ let characters = &whitespace.characters;
394+
393 let mut spans = Vec::new();
395 let mut spans = Vec::new();
394 let mut visual_x = 0u16;
396 let mut visual_x = 0u16;
395 let mut line = 0u16;
397 let mut line = 0u16;
396 let tab_width = doc.tab_width();
398 let tab_width = doc.tab_width();
397 let tab = if whitespace.render.tab() == WhitespaceRenderValue::All {
399 let tab = if whitespace.render.tab() == WhitespaceRenderValue::All {
398− (1..tab_width).fold(whitespace.characters.tab.to_string(), |s, _| s + " ")
400+ std::iter::once(characters.tab)
401+ .chain(std::iter::repeat(characters.tabpad).take(tab_width - 1))
402+ .collect()
399 } else {
403 } else {
400 " ".repeat(tab_width)
404 " ".repeat(tab_width)
401 };
405 };
402− let space = whitespace.characters.space.to_string();
406+ let space = characters.space.to_string();
403− let nbsp = whitespace.characters.nbsp.to_string();
407+ let nbsp = characters.nbsp.to_string();
404 let newline = if whitespace.render.newline() == WhitespaceRenderValue::All {
408 let newline = if whitespace.render.newline() == WhitespaceRenderValue::All {
405− whitespace.characters.newline.to_string()
409+ characters.newline.to_string()
406 } else {
410 } else {
407 " ".to_string()
411 " ".to_string()
408 };
412 };
helix-view/src/editor.rs+2
@@ -438,6 +438,7 @@ pub struct WhitespaceCharacters {
438 pub space: char,
438 pub space: char,
439 pub nbsp: char,
439 pub nbsp: char,
440 pub tab: char,
440 pub tab: char,
441+ pub tabpad: char,
441 pub newline: char,
442 pub newline: char,
442}
443}
443
444
@@ -448,6 +449,7 @@ impl Default for WhitespaceCharacters {
448 nbsp: '⍽', // U+237D
449 nbsp: '⍽', // U+237D
449 tab: '→', // U+2192
450 tab: '→', // U+2192
450 newline: '⏎', // U+23CE
451 newline: '⏎', // U+23CE
452+ tabpad: ' ',
451 }
453 }
452 }
454 }
453}
455}