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
}
pull/8/head
Blaž Hrastnik 4 years ago
parent 7a1ff5e45f
commit 8c82f8f140

@ -78,6 +78,8 @@ fn calculate_indentation(node: Option<Node>, newline: bool) -> usize {
"field_expression", "field_expression",
// //
"where_clause", "where_clause",
//
"use_list",
]; ];
let outdent = &["where", "}", "]", ")"]; let outdent = &["where", "}", "]", ")"];
@ -213,6 +215,12 @@ mod test {
fn test_suggested_indent_for_line() { fn test_suggested_indent_for_line() {
let doc = Rope::from( let doc = Rope::from(
" "
use std::{
io::{self, stdout, Stdout, Write},
path::PathBuf,
sync::Arc,
time::Duration,
}
mod test { mod test {
fn hello_world() { fn hello_world() {
1 + 1; 1 + 1;

@ -644,7 +644,7 @@ pub fn open_below(cx: &mut Context) {
let indent_level = helix_core::indent::suggested_indent_for_pos( let indent_level = helix_core::indent::suggested_indent_for_pos(
doc.syntax.as_ref(), doc.syntax.as_ref(),
&doc.state, &doc.state,
index, index - 1, // need to match the indentation to the prev line
true, true,
); );
let indent = " ".repeat(TAB_WIDTH).repeat(indent_level); let indent = " ".repeat(TAB_WIDTH).repeat(indent_level);

Loading…
Cancel
Save