make fmt_comments_only more general

This commit is contained in:
Sébastien Besnier 2020-11-15 10:26:14 +01:00
parent bc203371be
commit 25192fca10
4 changed files with 55 additions and 76 deletions

View file

@ -1,5 +1,5 @@
use crate::annotation::{Formattable, Newlines, Parens};
use crate::spaces::{fmt_comments_only, fmt_spaces};
use crate::spaces::{fmt_comments_only, fmt_spaces, NewlineAt};
use bumpalo::collections::String;
use roc_parse::ast::{Base, Pattern};
@ -133,7 +133,7 @@ impl<'a> Formattable<'a> for Pattern<'a> {
// Space
SpaceBefore(sub_pattern, spaces) => {
if !sub_pattern.is_multiline() {
fmt_comments_only(buf, spaces.iter(), indent)
fmt_comments_only(buf, spaces.iter(), NewlineAt::Bottom, indent)
} else {
fmt_spaces(buf, spaces.iter(), indent);
}
@ -143,7 +143,7 @@ impl<'a> Formattable<'a> for Pattern<'a> {
sub_pattern.format_with_options(buf, parens, newlines, indent);
// if only_comments {
if !sub_pattern.is_multiline() {
fmt_comments_only(buf, spaces.iter(), indent)
fmt_comments_only(buf, spaces.iter(), NewlineAt::Bottom, indent)
} else {
fmt_spaces(buf, spaces.iter(), indent);
}