From 2c60798b00cc9b8efc9fdbec304a7ea04d11de4c Mon Sep 17 00:00:00 2001 From: unrelentingtech Date: Sat, 30 Apr 2022 03:48:52 +0300 Subject: feat(ui): add nbsp (non-breaking space) to rendered whitespace (#2322) --- helix-term/src/ui/editor.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'helix-term/src/ui') 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 -- cgit v1.2.3-70-g09d2