on master help sign in
indent: use_list indentation, fix indentation bug on open_below

use std::{ time::Duration // <- pressing `o` here would use }'s indent instead of prev line }

commit8c82f8f140f45a76414fa28e842aabfbeffa864e authorBlaž Hrastnik <blaz@mxxn.io> dateFri 19 Feb 2021, 14:55 (6 years ago) parent7a1ff5e
2 files changed+9−1
helix-core/src/indent.rs+8 helix-term/src/commands.rs+1−1
helix-core/src/indent.rs+8
@@ -78,6 +78,8 @@ fn calculate_indentation(node: Option<Node>, newline: bool) -> usize {
7878 "field_expression",
7979 //
8080 "where_clause",
81+ //
82+ "use_list",
8183 ];
8284
8385 let outdent = &["where", "}", "]", ")"];
@@ -213,6 +215,12 @@ mod test {
213215 fn test_suggested_indent_for_line() {
214216 let doc = Rope::from(
215217 "
218+use std::{
219+ io::{self, stdout, Stdout, Write},
220+ path::PathBuf,
221+ sync::Arc,
222+ time::Duration,
223+}
216224mod test {
217225 fn hello_world() {
218226 1 + 1;
helix-term/src/commands.rs+1−1
@@ -644,7 +644,7 @@ pub fn open_below(cx: &mut Context) {
644644 let indent_level = helix_core::indent::suggested_indent_for_pos(
645645 doc.syntax.as_ref(),
646646 &doc.state,
647− index,
647+ index - 1, // need to match the indentation to the prev line
648648 true,
649649 );
650650 let indent = " ".repeat(TAB_WIDTH).repeat(indent_level);