on master help sign in
Fix indentation level calculation for lines mixing tabs and spaces (#6278)
3905243Stanisław Borowy
helix-core/src/indent.rs+2−1
@@ -4,6 +4,7 @@ use tree_sitter::{Query, QueryCursor, QueryPredicateArg};
4
4
5use crate::{
5use crate::{
6 chars::{char_is_line_ending, char_is_whitespace},
6 chars::{char_is_line_ending, char_is_whitespace},
7+ graphemes::tab_width_at,
7 syntax::{LanguageConfiguration, RopeProvider, Syntax},
8 syntax::{LanguageConfiguration, RopeProvider, Syntax},
8 tree_sitter::Node,
9 tree_sitter::Node,
9 Rope, RopeSlice,
10 Rope, RopeSlice,
@@ -189,7 +190,7 @@ pub fn indent_level_for_line(line: RopeSlice, tab_width: usize, indent_width: us
189 let mut len = 0;
190 let mut len = 0;
190 for ch in line.chars() {
191 for ch in line.chars() {
191 match ch {
192 match ch {
192− '\t' => len += tab_width,
193+ '\t' => len += tab_width_at(len, tab_width as u16),
193 ' ' => len += 1,
194 ' ' => len += 1,
194 _ => break,
195 _ => break,
195 }
196 }