Skip to content

Commit

Permalink
Render overlapping marks
Browse files Browse the repository at this point in the history
This renders overlapping multiline marks on the same lines of source code. This means that the following example:

```
error[E0308]: match arms have incompatible types

   ┌── codespan/src/file.rs:1:9 ───
   │
 1 │ ╭         match line_index.compare(self.last_line_index()) {
 2 │ │             Ordering::Less => Ok(self.line_starts()[line_index.to_usize()]),
 3 │ │             Ordering::Equal => Ok(self.source_span().end()),
 4 │ │             Ordering::Greater => LineIndexOutOfBoundsError {
 5 │ │                 given: line_index,
 6 │ │                 max: self.last_line_index(),
 7 │ │             },
 8 │ │         }
   │ ╰─────────' `match` arms have incompatible types
   ·
 2 │               Ordering::Less => Ok(self.line_starts()[line_index.to_usize()]),
   │                                 --------------------------------------------- this is found to be of type `Result<ByteIndex, LineIndexOutOfBoundsError>`
 3 │               Ordering::Equal => Ok(self.source_span().end()),
   │                                  ---------------------------- this is found to be of type `Result<ByteIndex, LineIndexOutOfBoundsError>`
 4 │               Ordering::Greater => LineIndexOutOfBoundsError {
   │ ╭──────────────────────────────────^
 5 │ │                 given: line_index,
 6 │ │                 max: self.last_line_index(),
 7 │ │             },
   │ ╰─────────────^ expected enum `Result`, found struct `LineIndexOutOfBoundsError`
   │
   = expected type `Result<ByteIndex, LineIndexOutOfBoundsError>`
        found type `LineIndexOutOfBoundsError`
```

…is now rendered as:

```
error[E0308]: match arms have incompatible types

   ┌── codespan/src/file.rs:1:9 ───
   │
 1 │   ╭         match line_index.compare(self.last_line_index()) {
 2 │   │             Ordering::Less => Ok(self.line_starts()[line_index.to_usize()]),
   │   │                               --------------------------------------------- this is found to be of type `Result<ByteIndex, LineIndexOutOfBoundsError>`
 3 │   │             Ordering::Equal => Ok(self.source_span().end()),
   │   │                                ---------------------------- this is found to be of type `Result<ByteIndex, LineIndexOutOfBoundsError>`
 4 │   │             Ordering::Greater => LineIndexOutOfBoundsError {
   │ ╭─│──────────────────────────────────^
 5 │ │ │                 given: line_index,
 6 │ │ │                 max: self.last_line_index(),
 7 │ │ │             },
   │ ╰─│─────────────^ expected enum `Result`, found struct `LineIndexOutOfBoundsError`
 8 │   │         }
   │   ╰─────────' `match` arms have incompatible types
   │
   = expected type `Result<ByteIndex, LineIndexOutOfBoundsError>`
        found type `LineIndexOutOfBoundsError`
```

Closes #100
  • Loading branch information
brendanzab committed Mar 24, 2020
1 parent ca075aa commit f95cdb2
Show file tree
Hide file tree
Showing 7 changed files with 418 additions and 390 deletions.
17 changes: 6 additions & 11 deletions codespan-reporting/assets/readme_preview.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f95cdb2

Please sign in to comment.