From e869533b99eecdc133ed3b4bedc22d24dc2c2dd9 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 20 Jun 2022 18:37:09 +0200 Subject: Fix bug with tabs --- src/tokenizer.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/tokenizer.rs b/src/tokenizer.rs index de27d12..d31c8c5 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -704,7 +704,12 @@ pub fn as_codes(value: &str) -> Vec { // Send a tab and virtual spaces. '\t' => { // To do: is this correct? - let virtual_spaces = TAB_SIZE - (column % TAB_SIZE); + let remainder = column % TAB_SIZE; + let virtual_spaces = if remainder == 0 { + 0 + } else { + TAB_SIZE - remainder + }; codes.push(Code::Char(char)); column += 1; let mut index = 0; -- cgit