Skip to content

Commit

Permalink
Allow tab virtual whitespace to be long string
Browse files Browse the repository at this point in the history
  • Loading branch information
A-Walrus committed Aug 16, 2022
1 parent 2968756 commit 043ea52
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion book/src/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ Options for rendering whitespace with visible characters. Use `:set whitespace.r
| Key | Description | Default |
|-----|-------------|---------|
| `render` | Whether to render whitespace. May either be `"all"` or `"none"`, or a table with sub-keys `space`, `tab`, and `newline`. | `"none"` |
| `characters` | Literal characters to use when rendering whitespace. Sub-keys may be any of `tab`, `space`, `nbsp` or `newline` | See example below |
| `characters` | Literal characters to use when rendering whitespace. Sub-keys may be any of `tab`, `space`, `nbsp` or `newline`. Tab can be set to a string of multiple characters which will be truncated and padded to the apropriate length. | See example below |

Example

Expand Down
3 changes: 2 additions & 1 deletion helix-term/src/ui/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,8 @@ impl EditorView {
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 + " ")
let tab_config = whitespace.characters.tab.clone();
(tab_config.width()..tab_width).fold(tab_config, |s, _| s + " ")
} else {
" ".repeat(tab_width)
};
Expand Down
10 changes: 5 additions & 5 deletions helix-view/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,17 +437,17 @@ impl WhitespaceRender {
pub struct WhitespaceCharacters {
pub space: char,
pub nbsp: char,
pub tab: char,
pub tab: String,
pub newline: char,
}

impl Default for WhitespaceCharacters {
fn default() -> Self {
Self {
space: '·', // U+00B7
nbsp: '⍽', // U+237D
tab: '→', // U+2192
newline: '⏎', // U+23CE
space: '·', // U+00B7
nbsp: '⍽', // U+237D
tab: "→".into(), // U+2192
newline: '⏎', // U+23CE
}
}
}
Expand Down

0 comments on commit 043ea52

Please sign in to comment.