Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug where an unexpected newline is inserted when formatting fun () -> ?assertMatch(..., ...) end.. #108

Merged
merged 1 commit into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions efmt_core/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,16 @@ impl Formatter {
return;
}

if self.skipping {
self.pending_blank = Some(Blank::Newline(n));
if self.single_line_mode {
self.write_space();
return;
}
self.pending_blank = None;

if self.single_line_mode {
self.write_space();
if self.skipping {
self.pending_blank = Some(Blank::Newline(n));
return;
}
self.pending_blank = None;

let indent = self.cancel_last_spaces();
for c in self.buf.chars().rev() {
Expand Down
9 changes: 7 additions & 2 deletions efmt_core/src/items/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,15 +618,20 @@ mod tests {

#[test]
fn assert_match() {
let texts = [indoc::indoc! {"
let texts = [
indoc::indoc! {"
foo() ->
?assertMatch(ok when true, Value),
?assertNotMatch([A, B, C]
when is_binary(B) andalso
is_integer(C),
Value),
ok.
"}];
"},
indoc::indoc! {"
foo() -> fun() -> ?assertMatch(ok, Value) end.
"},
];
for text in texts {
crate::assert_format!(text, Module);
}
Expand Down
Loading