@@ -48,7 +48,6 @@ fn calculate_indentation(node: Option<Node>, newline: bool) -> usize {
4848
4949 // Hardcoded for rust for now
5050 let indent_scopes = &[
51− // indent except first or block?
5251 "while_expression",
5352 "for_expression",
5453 "loop_expression",
@@ -56,14 +55,9 @@ fn calculate_indentation(node: Option<Node>, newline: bool) -> usize {
5655 "if_let_expression",
5756 // "match_expression",
5857 // "match_arm",
59− ];
6058
61− // this is for multiline things, such as:
62− // self.method()
63− // .chain()
64− // .chain()
65− // where the first line isn't indented
66− let indent_except_first_scopes = &[
59+ // indent_except_first_scopes
60+ "use_list",
6761 "block",
6862 "match_block",
6963 "arguments",
@@ -74,10 +68,7 @@ fn calculate_indentation(node: Option<Node>, newline: bool) -> usize {
7468 // "closure_expression",
7569 "binary_expression",
7670 "field_expression",
77− //
7871 "where_clause",
79− //
80− "use_list",
8172 ];
8273
8374 let outdent = &["where", "}", "]", ")"];
@@ -92,36 +83,20 @@ fn calculate_indentation(node: Option<Node>, newline: bool) -> usize {
9283 // if we're calculating indentation for a brand new line then the current node will become the
9384 // parent node. We need to take it's indentation level into account too.
9485 let node_kind = node.kind();
95− if newline
96− && (indent_scopes.contains(&node_kind) || indent_except_first_scopes.contains(&node_kind))
97− {
86+ if newline && indent_scopes.contains(&node_kind) {
9887 increment += 1;
9988 }
10089
10190 while let Some(parent) = node.parent() {
102− let not_first_sibling = node.prev_sibling().is_some();
103− let not_last_sibling = node.next_sibling().is_some();
104− let not_first_or_last_sibling = not_first_sibling && not_last_sibling;
105−
10691 let parent_kind = parent.kind();
10792 let start = parent.start_position().row;
10893
10994 // detect deeply nested indents in the same line
95+ // .map(|a| { <-- ({ is two scopes
96+ // let len = 1; <-- indents one level
97+ // }) <-- }) is two scopes
11098 let starts_same_line = start == prev_start;
11199
112− // log::error!(
113− // "name: {}\tparent: {}\trange:\t{} {}\tfirst={:?}\tlast={:?} start={} prev={} same_line={}",
114− // node.kind(),
115− // parent.kind(),
116− // node.range().start_point,
117− // node.range().end_point,
118− // node.prev_sibling().is_none(),
119− // node.next_sibling().is_none(),
120− // node.start_position(),
121− // prev_start,
122− // starts_same_line
123− // );
124−
125100 if outdent.contains(&node.kind()) && !starts_same_line {
126101 // we outdent by skipping the rules for the current level and jumping up
127102 // node = parent;
@@ -129,15 +104,7 @@ fn calculate_indentation(node: Option<Node>, newline: bool) -> usize {
129104 // continue;
130105 }
131106
132− // TODO: problem seems to be, ({ is two scopes that merge into one.
133− // so when seeing } we're supposed to jump all the way out of both scopes, but we only do
134− // so for one.
135− // .map(|a| {
136− // let len = 1;
137− // })
138−
139− if (indent_scopes.contains(&parent_kind) // && not_first_or_last_sibling
140− || indent_except_first_scopes.contains(&parent_kind))
107+ if indent_scopes.contains(&parent_kind) // && not_first_or_last_sibling
141108 && !starts_same_line
142109 {
143110 // println!("is_scope {}", parent_kind);
@@ -145,11 +112,6 @@ fn calculate_indentation(node: Option<Node>, newline: bool) -> usize {
145112 increment += 1
146113 }
147114
148− // TODO: detect deeply nested indents in same line:
149− // std::panic::set_hook(Box::new(move |info| {
150− // hook(info); <-- indent here is 1
151− // }));
152−
153115 // if last_scope && increment > 0 && ...{ ignore }
154116
155117 node = parent;