on master help sign in
Fix indentation level calculation for lines mixing tabs and spaces (#6278)
commit39052433edd4dcbd3a9714e6e3036cbd46ebc959 authorStanisław Borowy <stabor7@protonmail.com> dateSun 12 Mar 2023, 18:12 (4 years ago) parent6e432e8
1 file changed+2−1
helix-core/src/indent.rs+2−1
helix-core/src/indent.rs+2−1
@@ -4,6 +4,7 @@ use tree_sitter::{Query, QueryCursor, QueryPredicateArg};
44
55use crate::{
66 chars::{char_is_line_ending, char_is_whitespace},
7+ graphemes::tab_width_at,
78 syntax::{LanguageConfiguration, RopeProvider, Syntax},
89 tree_sitter::Node,
910 Rope, RopeSlice,
@@ -189,7 +190,7 @@ pub fn indent_level_for_line(line: RopeSlice, tab_width: usize, indent_width: us
189190 let mut len = 0;
190191 for ch in line.chars() {
191192 match ch {
192− '\t' => len += tab_width,
193+ '\t' => len += tab_width_at(len, tab_width as u16),
193194 ' ' => len += 1,
194195 _ => break,
195196 }