Fix reporting tests

This commit is contained in:
Richard Feldman 2022-11-24 10:12:38 -05:00
parent d2900630f2
commit ed0c64ca7c
No known key found for this signature in database
GPG key ID: F1F21AA5B1D9E43B
3 changed files with 65 additions and 41 deletions

View file

@ -1238,9 +1238,8 @@ fn to_bad_ident_expr_report<'b>(
lines.convert_region(surroundings),
lines.convert_region(region),
),
alloc.concat([alloc.reflow(
r"I recommend using camelCase, it is the standard in the Roc ecosystem.",
)]),
alloc.concat([alloc
.reflow(r"I recommend using camelCase. It's the standard style in Roc code!")]),
])
}

View file

@ -549,8 +549,8 @@ impl<'a> RocDocAllocator<'a> {
let this_line_number_length = line_number.len();
let line = self.src_lines[i as usize];
let rest_of_line = if !line.trim().is_empty() {
let is_line_empty = line.trim().is_empty();
let rest_of_line = if !is_line_empty {
self.text(line).indent(indent)
} else {
self.nil()
@ -572,11 +572,17 @@ impl<'a> RocDocAllocator<'a> {
.append(self.text(GUTTER_BAR).annotate(Annotation::GutterBar))
.append(rest_of_line)
} else {
self.text(" ".repeat(max_line_number_length - this_line_number_length))
let up_to_gutter = self
.text(" ".repeat(max_line_number_length - this_line_number_length))
.append(self.text(line_number).annotate(Annotation::LineNumber))
.append(self.text(GUTTER_BAR).annotate(Annotation::GutterBar))
.append(self.text(" "))
.append(rest_of_line)
.append(self.text(GUTTER_BAR).annotate(Annotation::GutterBar));
if is_line_empty {
// Don't put an trailing space after the gutter
up_to_gutter
} else {
up_to_gutter.append(self.text(" ")).append(rest_of_line)
}
};
result = result.append(source_line);
@ -667,8 +673,8 @@ impl<'a> RocDocAllocator<'a> {
let this_line_number_length = line_number.len();
let line: &str = self.src_lines.get(i as usize).unwrap_or(&"");
let rest_of_line = if !line.trim().is_empty() {
let is_line_empty = line.trim().is_empty();
let rest_of_line = if !is_line_empty {
self.text(line)
.annotate(Annotation::CodeBlock)
.indent(indent)
@ -691,11 +697,17 @@ impl<'a> RocDocAllocator<'a> {
.append(self.text(GUTTER_BAR).annotate(Annotation::GutterBar))
.append(rest_of_line)
} else {
self.text(" ".repeat(max_line_number_length - this_line_number_length))
let up_to_gutter = self
.text(" ".repeat(max_line_number_length - this_line_number_length))
.append(self.text(line_number).annotate(Annotation::LineNumber))
.append(self.text(GUTTER_BAR).annotate(Annotation::GutterBar))
.append(self.text(" "))
.append(rest_of_line)
.append(self.text(GUTTER_BAR).annotate(Annotation::GutterBar));
if is_line_empty {
// Don't put an trailing space after the gutter
up_to_gutter
} else {
up_to_gutter.append(self.text(" ")).append(rest_of_line)
}
};
result = result.append(source_line);