From 8c82f8f140f45a76414fa28e842aabfbeffa864e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Fri, 19 Feb 2021 14:55:53 +0900 Subject: [PATCH] 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 } --- helix-core/src/indent.rs | 8 ++++++++ helix-term/src/commands.rs | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/helix-core/src/indent.rs b/helix-core/src/indent.rs index 49552b4f..68d5d7b0 100644 --- a/helix-core/src/indent.rs +++ b/helix-core/src/indent.rs @@ -78,6 +78,8 @@ fn calculate_indentation(node: Option, newline: bool) -> usize { "field_expression", // "where_clause", + // + "use_list", ]; let outdent = &["where", "}", "]", ")"]; @@ -213,6 +215,12 @@ mod test { fn test_suggested_indent_for_line() { let doc = Rope::from( " +use std::{ + io::{self, stdout, Stdout, Write}, + path::PathBuf, + sync::Arc, + time::Duration, +} mod test { fn hello_world() { 1 + 1; diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 4fe80971..95c98b10 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -644,7 +644,7 @@ pub fn open_below(cx: &mut Context) { let indent_level = helix_core::indent::suggested_indent_for_pos( doc.syntax.as_ref(), &doc.state, - index, + index - 1, // need to match the indentation to the prev line true, ); let indent = " ".repeat(TAB_WIDTH).repeat(indent_level);