diff options
author | unrelentingtech | 2022-04-30 00:48:52 +0000 |
---|---|---|
committer | GitHub | 2022-04-30 00:48:52 +0000 |
commit | 2c60798b00cc9b8efc9fdbec304a7ea04d11de4c (patch) | |
tree | 9608c0eb3a94b527931f4a7d51b8975c75226764 /helix-term/src/ui | |
parent | e4c261809980fa17436a8e87cf7e56ddda8bcb68 (diff) |
feat(ui): add nbsp (non-breaking space) to rendered whitespace (#2322)
Diffstat (limited to 'helix-term/src/ui')
-rw-r--r-- | helix-term/src/ui/editor.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 5ceff39e..52e58163 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -370,6 +370,7 @@ impl EditorView { " ".repeat(tab_width) }; let space = whitespace.characters.space.to_string(); + let nbsp = whitespace.characters.nbsp.to_string(); let newline = if whitespace.render.newline() == WhitespaceRenderValue::All { whitespace.characters.newline.to_string() } else { @@ -406,6 +407,14 @@ impl EditorView { " " }; + let nbsp = if whitespace.render.nbsp() == WhitespaceRenderValue::All + && text.len_chars() < end + { +   + } else { + " " + }; + use helix_core::graphemes::{grapheme_width, RopeGraphemes}; for grapheme in RopeGraphemes::new(text) { @@ -445,6 +454,9 @@ impl EditorView { } else if grapheme == " " { is_whitespace = true; (space, 1) + } else if grapheme == "\u{00A0}" { + is_whitespace = true; + (nbsp, 1) } else { is_whitespace = false; // Cow will prevent allocations if span contained in a single slice |