This commit is contained in:
Esteban Küber 2019-08-14 11:44:56 -07:00
parent f08b036cc7
commit 45a6be5458
5 changed files with 14 additions and 15 deletions

View File

@ -367,7 +367,8 @@ impl EmitterWriter {
&source_string[margin.left(line_len)..margin.right(line_len)],
Style::Quotation,
);
if margin.was_cut_left() { // We have stripped some code/whitespace from the beginning, make it clear.
if margin.was_cut_left() {
// We have stripped some code/whitespace from the beginning, make it clear.
buffer.puts(line_offset, code_offset, "...", Style::LineNumber);
}
if margin.was_cut_right(line_len) {
@ -403,7 +404,7 @@ impl EmitterWriter {
// ^^ ^ ^^^ ^^^^ ^^^ we don't care about code too far to the right of a span, we trim it
// | | | |
// | | | actual code found in your source code and the spans we use to mark it
// | | when there's too much wasted space to the left, we trim it to focus where it matters
// | | when there's too much wasted space to the left, trim it
// | vertical divider between the column number and the code
// column number
@ -1251,18 +1252,16 @@ impl EmitterWriter {
let mut label_right_margin = 0;
let mut max_line_len = 0;
for line in &annotated_file.lines {
max_line_len = max(
max_line_len,
annotated_file.file.get_line(line.line_index - 1).map(|s| s.len()).unwrap_or(0),
);
max_line_len = max(max_line_len, annotated_file.file
.get_line(line.line_index - 1)
.map(|s| s.len())
.unwrap_or(0));
for ann in &line.annotations {
span_right_margin = max(span_right_margin, ann.start_col);
span_right_margin = max(span_right_margin, ann.end_col);
label_right_margin = max(
label_right_margin,
// TODO: account for labels not in the same line
ann.end_col + ann.label.as_ref().map(|l| l.len() + 1).unwrap_or(0),
);
// FIXME: account for labels not in the same line
let label_right = ann.label.as_ref().map(|l| l.len() + 1).unwrap_or(0);
label_right_margin = max(label_right_margin, ann.end_col + label_right);
}
}

View File

@ -1,4 +1,4 @@
// ignore-tidy-length
// ignore-tidy-linelength
fn main() {
let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = 42; let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = ();

View File

@ -1,4 +1,4 @@
// ignore-tidy-length
// ignore-tidy-linelength
fn main() {
let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = 42; let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = ();

View File

@ -1,4 +1,4 @@
// ignore-tidy-length
// ignore-tidy-linelength
fn foo() -> usize {
()

View File

@ -1,4 +1,4 @@
// ignore-tidy-length
// ignore-tidy-linelength
fn main() {
let _: () = 42;