Fix to not add extra spaces when formatting call (#6652)
This commit is contained in:
@ -126,7 +126,7 @@ fn armRestProfile(@plane, offset) {
|
||||
|
||||
export fn armRest(@plane, offset) {
|
||||
path = armRestPath( offsetPlane(plane, offset = offset))
|
||||
profile = armRestProfile( offsetPlane(-XZ, offset = 20), offset = -offset)
|
||||
profile = armRestProfile(offsetPlane(-XZ, offset = 20), offset = -offset)
|
||||
sweep(profile, path = path)
|
||||
return 0
|
||||
}
|
||||
|
@ -377,7 +377,7 @@ impl CallExpression {
|
||||
impl CallExpressionKw {
|
||||
fn recast_args(&self, options: &FormatOptions, indentation_level: usize, ctxt: ExprContext) -> Vec<String> {
|
||||
let mut arg_list = if let Some(first_arg) = &self.unlabeled {
|
||||
vec![first_arg.recast(options, indentation_level, ctxt)]
|
||||
vec![first_arg.recast(options, indentation_level, ctxt).trim().to_owned()]
|
||||
} else {
|
||||
Vec::with_capacity(self.arguments.len())
|
||||
};
|
||||
@ -2584,6 +2584,58 @@ sketch002 = startSketchOn({
|
||||
assert_eq!(actual, input);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unparse_call_inside_function_single_line() {
|
||||
let input = r#"fn foo() {
|
||||
toDegrees(atan(0.5), foo = 1)
|
||||
return 0
|
||||
}
|
||||
"#;
|
||||
let ast = crate::parsing::top_level_parse(input).unwrap();
|
||||
let actual = ast.recast(&FormatOptions::new(), 0);
|
||||
assert_eq!(actual, input);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unparse_call_inside_function_args_multiple_lines() {
|
||||
let input = r#"fn foo() {
|
||||
toDegrees(
|
||||
atan(0.5),
|
||||
foo = 1,
|
||||
bar = 2,
|
||||
baz = 3,
|
||||
qux = 4,
|
||||
)
|
||||
return 0
|
||||
}
|
||||
"#;
|
||||
let ast = crate::parsing::top_level_parse(input).unwrap();
|
||||
let actual = ast.recast(&FormatOptions::new(), 0);
|
||||
assert_eq!(actual, input);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unparse_call_inside_function_single_arg_multiple_lines() {
|
||||
let input = r#"fn foo() {
|
||||
toDegrees(
|
||||
[
|
||||
profile0,
|
||||
profile1,
|
||||
profile2,
|
||||
profile3,
|
||||
profile4,
|
||||
profile5
|
||||
],
|
||||
key = 1,
|
||||
)
|
||||
return 0
|
||||
}
|
||||
"#;
|
||||
let ast = crate::parsing::top_level_parse(input).unwrap();
|
||||
let actual = ast.recast(&FormatOptions::new(), 0);
|
||||
assert_eq!(actual, input);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn recast_objects_with_comments() {
|
||||
use winnow::Parser;
|
||||
|
@ -605,19 +605,19 @@ flowchart LR
|
||||
84 --- 147
|
||||
84 --- 233
|
||||
87 --- 169
|
||||
87 x--> 184
|
||||
87 x--> 183
|
||||
87 --- 212
|
||||
87 --- 257
|
||||
89 --- 168
|
||||
89 x--> 184
|
||||
89 x--> 183
|
||||
89 --- 214
|
||||
89 --- 258
|
||||
90 --- 167
|
||||
90 x--> 184
|
||||
90 x--> 183
|
||||
90 --- 211
|
||||
90 --- 256
|
||||
92 --- 166
|
||||
92 x--> 184
|
||||
92 x--> 183
|
||||
92 --- 213
|
||||
92 --- 259
|
||||
119 --- 162
|
||||
@ -865,10 +865,10 @@ flowchart LR
|
||||
221 <--x 181
|
||||
222 <--x 181
|
||||
193 <--x 182
|
||||
211 <--x 183
|
||||
212 <--x 183
|
||||
213 <--x 183
|
||||
214 <--x 183
|
||||
211 <--x 184
|
||||
212 <--x 184
|
||||
213 <--x 184
|
||||
214 <--x 184
|
||||
203 <--x 186
|
||||
204 <--x 186
|
||||
205 <--x 186
|
||||
|
@ -241,8 +241,8 @@ flowchart LR
|
||||
7["Plane<br>[334, 354, 8]"]
|
||||
8["Plane<br>[3807, 3842, 8]"]
|
||||
9["Plane<br>[3807, 3842, 8]"]
|
||||
10["Plane<br>[3873, 3902, 8]"]
|
||||
11["Plane<br>[3873, 3902, 8]"]
|
||||
10["Plane<br>[3871, 3900, 8]"]
|
||||
11["Plane<br>[3871, 3900, 8]"]
|
||||
12["StartSketchOnPlane<br>[2700, 2720, 8]"]
|
||||
13["StartSketchOnPlane<br>[1737, 1757, 8]"]
|
||||
14["StartSketchOnPlane<br>[3258, 3278, 8]"]
|
||||
@ -268,8 +268,8 @@ flowchart LR
|
||||
234["Sweep Extrusion<br>[2618, 2642, 8]"]
|
||||
235["Sweep Extrusion<br>[3180, 3204, 8]"]
|
||||
236["Sweep Extrusion<br>[3180, 3204, 8]"]
|
||||
237["Sweep Sweep<br>[3924, 3951, 8]"]
|
||||
238["Sweep Sweep<br>[3924, 3951, 8]"]
|
||||
237["Sweep Sweep<br>[3922, 3949, 8]"]
|
||||
238["Sweep Sweep<br>[3922, 3949, 8]"]
|
||||
239[Wall]
|
||||
240[Wall]
|
||||
241[Wall]
|
||||
|
Reference in New Issue
Block a user