aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorBlaž Hrastnik2022-03-04 02:01:33 +0000
committerBlaž Hrastnik2022-03-04 02:01:33 +0000
commitfd02d1bf8966754624c733790c20bb8431e1eb54 (patch)
treed0f4480f9190f8048d70acceca1711cc2e999a34 /helix-term/src
parent5f386fa355d2f3e95a890c2d63d95b05ddca23a4 (diff)
Fix tab rendering to use dynamic tab width
Each tab is just wide enough to round to the nearest tab stop. Refs #1243
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/ui/editor.rs3
1 files changed, 2 insertions, 1 deletions
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