Skip to content

Commit 947d638

Browse files
committed
fix: Only warn trailing commas in calls
1 parent e225203 commit 947d638

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/diagnostics.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,10 @@ pub fn diagnostics_syntax(node: Node, rope: &Rope) -> Vec<Diagnostic> {
234234
handled_error |= traverse(cursor, diagnostics, rope);
235235

236236
if !cursor.goto_next_sibling() {
237+
cursor.goto_parent();
237238
break;
238239
}
239240
}
240-
241-
cursor.goto_parent();
242241
}
243242

244243
if !handled_error && node.is_error() {
@@ -316,22 +315,23 @@ pub fn diagnostics_semantics(node: Node, rope: &Rope, config: Config) -> Vec<Dia
316315
}
317316

318317
if !cursor.goto_next_sibling() {
318+
cursor.goto_parent();
319319
break;
320320
}
321321
}
322+
322323
// note: we only check trailing commas for call not subset
323324
if let Some(last_comma) = last_comma
324325
&& state.check_trailing_commas
325326
{
326-
state.check_trailing_commas(false);
327327
diagnostics.push(error(
328328
last_comma,
329329
"Unexpected comma after last argument".into(),
330330
));
331331
}
332-
333-
cursor.goto_parent();
334332
}
333+
334+
state.check_trailing_commas(false);
335335
}
336336
"binary_operator" => {
337337
if let (Some(lhs), Some(operator)) = (
@@ -404,11 +404,10 @@ pub fn diagnostics_semantics(node: Node, rope: &Rope, config: Config) -> Vec<Dia
404404
traverse(cursor, diagnostics, rope, config, state);
405405

406406
if !cursor.goto_next_sibling() {
407+
cursor.goto_parent();
407408
break;
408409
}
409410
}
410-
411-
cursor.goto_parent();
412411
}
413412
}
414413

src/utils.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,11 @@ pub fn format_node(node: Node) -> String {
155155
traverse(cursor, output);
156156

157157
if !cursor.goto_next_sibling() {
158+
cursor.goto_parent();
158159
break;
159160
}
160161
}
161162

162-
cursor.goto_parent();
163-
164163
output.push('\n');
165164
output.push_str(&indent);
166165
output.push(')');

0 commit comments

Comments
 (0)