diff options
Diffstat (limited to 'helix-term/src')
-rw-r--r-- | helix-term/src/commands.rs | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index a3c9f0b4..fb55ca2a 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -3364,8 +3364,8 @@ pub mod insert { let count = cx.count(); let (view, doc) = current_ref!(cx.editor); let text = doc.text().slice(..); - let indent_unit = doc.indent_style.as_str(); - let tab_size = doc.tab_width(); + let tab_width = doc.tab_width(); + let indent_width = doc.indent_width(); let auto_pairs = doc.auto_pairs(cx.editor); let transaction = @@ -3386,18 +3386,11 @@ pub mod insert { None, ) } else { - let unit_len = indent_unit.chars().count(); - // NOTE: indent_unit always contains 'only spaces' or 'only tab' according to `IndentStyle` definition. - let unit_size = if indent_unit.starts_with('\t') { - tab_size * unit_len - } else { - unit_len - }; let width: usize = fragment .chars() .map(|ch| { if ch == '\t' { - tab_size + tab_width } else { // it can be none if it still meet control characters other than '\t' // here just set the width to 1 (or some value better?). @@ -3405,9 +3398,9 @@ pub mod insert { } }) .sum(); - let mut drop = width % unit_size; // round down to nearest unit + let mut drop = width % indent_width; // round down to nearest unit if drop == 0 { - drop = unit_size + drop = indent_width }; // if it's already at a unit, consume a whole unit let mut chars = fragment.chars().rev(); let mut start = pos; @@ -3949,7 +3942,7 @@ fn unindent(cx: &mut Context) { let lines = get_lines(doc, view.id); let mut changes = Vec::with_capacity(lines.len()); let tab_width = doc.tab_width(); - let indent_width = count * tab_width; + let indent_width = count * doc.indent_width(); for line_idx in lines { let line = doc.text().line(line_idx); |