on master help sign in
indent: use_list indentation, fix indentation bug on open_below
8c82f8fBlaž Hrastnik
helix-core/src/indent.rs+8
@@ -78,6 +78,8 @@ fn calculate_indentation(node: Option<Node>, newline: bool) -> usize {
78 "field_expression",
78 "field_expression",
79 //
79 //
80 "where_clause",
80 "where_clause",
81+ //
82+ "use_list",
81 ];
83 ];
82
84
83 let outdent = &["where", "}", "]", ")"];
85 let outdent = &["where", "}", "]", ")"];
@@ -213,6 +215,12 @@ mod test {
213 fn test_suggested_indent_for_line() {
215 fn test_suggested_indent_for_line() {
214 let doc = Rope::from(
216 let doc = Rope::from(
215 "
217 "
218+use std::{
219+ io::{self, stdout, Stdout, Write},
220+ path::PathBuf,
221+ sync::Arc,
222+ time::Duration,
223+}
216mod test {
224mod test {
217 fn hello_world() {
225 fn hello_world() {
218 1 + 1;
226 1 + 1;
helix-term/src/commands.rs+1−1
@@ -644,7 +644,7 @@ pub fn open_below(cx: &mut Context) {
644 let indent_level = helix_core::indent::suggested_indent_for_pos(
644 let indent_level = helix_core::indent::suggested_indent_for_pos(
645 doc.syntax.as_ref(),
645 doc.syntax.as_ref(),
646 &doc.state,
646 &doc.state,
647− index,
647+ index - 1, // need to match the indentation to the prev line
648 true,
648 true,
649 );
649 );
650 let indent = " ".repeat(TAB_WIDTH).repeat(indent_level);
650 let indent = " ".repeat(TAB_WIDTH).repeat(indent_level);