mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-22 18:19:54 -04:00
DEV: Handle grouped comments with embedded comments.
This commit is contained in:
parent
157f123355
commit
ff2aafeb98
@ -425,7 +425,15 @@ where
|
|||||||
},
|
},
|
||||||
Expression::Grouped(ref expr, _) => {
|
Expression::Grouped(ref expr, _) => {
|
||||||
write!(self.w, "(")?;
|
write!(self.w, "(")?;
|
||||||
|
if self.has_comment(expr.pos().line) {
|
||||||
|
self.curr_indent += self.indent_size;
|
||||||
|
did_indent = true;
|
||||||
|
write!(self.w, "\n")?;
|
||||||
|
}
|
||||||
self.render_expr(expr)?;
|
self.render_expr(expr)?;
|
||||||
|
if did_indent {
|
||||||
|
write!(self.w, "\n")?;
|
||||||
|
}
|
||||||
write!(self.w, ")")?;
|
write!(self.w, ")")?;
|
||||||
}
|
}
|
||||||
Expression::Import(_def) => {
|
Expression::Import(_def) => {
|
||||||
|
@ -360,3 +360,19 @@ fn test_reduce_func_operator_expression_with_embedded_comment() {
|
|||||||
let output = print_to_buffer(input);
|
let output = print_to_buffer(input);
|
||||||
assert_eq!(output, format!("{}\n", input.trim()));
|
assert_eq!(output, format!("{}\n", input.trim()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_map_func_operator_expression_with_embedded_comment() {
|
||||||
|
//let input = "// a comment\nfilter(foo, bar);";
|
||||||
|
let input = "// a comment\nmap(\n // another comment\n foo,\n // one more\n bar);";
|
||||||
|
let output = print_to_buffer(input);
|
||||||
|
assert_eq!(output, format!("{}\n", input.trim()));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_grouped_expression_with_embedded_comment() {
|
||||||
|
//let input = "// a comment\nfilter(foo, bar);";
|
||||||
|
let input = "// a comment\n(\n // a comment\n foo\n);";
|
||||||
|
let output = print_to_buffer(input);
|
||||||
|
assert_eq!(output, format!("{}\n", input.trim()));
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user