From fd02d1bf8966754624c733790c20bb8431e1eb54 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Fri, 4 Mar 2022 11:01:33 +0900 Subject: Fix tab rendering to use dynamic tab width Each tab is just wide enough to round to the nearest tab stop. Refs #1243 --- helix-term/src/ui/editor.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'helix-term/src/ui/editor.rs') diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index f9c5e55e..31a9bfc8 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -378,7 +378,8 @@ impl EditorView { let (grapheme, width) = if grapheme == "\t" { // make sure we display tab as appropriate amount of spaces - (tab.as_str(), tab_width) + let visual_tab_width = tab_width - (visual_x as usize % tab_width); + (&tab[..visual_tab_width], visual_tab_width) } else { // Cow will prevent allocations if span contained in a single slice // which should really be the majority case -- cgit v1.2.3-70-g09d2