Comments (3)
Yeah, overlapping spans are not really... well supported (read: supported). Mostly because I couldn't figure out how to support them well? What do you think this should render as?
My recommendation otherwise is to make sure your single-line spans aren't overlapping, which isn't great. We do have choices, I just don't know which one to pick. I'd love a PR if that's something you're interested in doing, though :)
from miette.
What do you think this should render as?
I think the main problem is that the here
label doesn't point at the beginning, end, or middle of the relevant source text. Just pointing at the beginning (or really anywhere within the span) could be better.
,----
1 | {foo,**,bar,baz}
: ^^^^^|^^^^^^^^^^
: `--|-- here
: `-- in this alternative
`----
Even better (and possibly easier to implement) may be to provide separate underlines for spans over more than one character. In this case, that could look something like the following.
,----
1 | {foo,**,bar,baz}
: ^^^^^^^^^^^^^^^^
: ^^ |
: | |
: | `-- in this alternative
: `----- here
`----
While it's a bit verbose, I think I would personally prefer this rendering since it makes the spans very clear. Any spans that refer to a single character could instead "punch through" a bit like the first example.
,----
1 | {foo,**,bar,baz}
: ^^^^^^^^^^^^|^^^
: ^^ | `-- you goofed right here too
: | |
: | `-- in this alternative
: `----- here
`----
I think this works so long as the difference between ^
and |
beneath the source text is consistent. For multiline source text, this may remain clear so long as the number of necessary underlines wrap with the lines.
,----
1 | Everything is okay. Oh No,
: ^^^|^^
: `-- uppercase?
2 | I was very wrong!
: ^^^^^^^^^^^^^^^^^
: | ^^^^
: | |
: | `-- so very
: `----- it happens
`----
,----
1 | Memory safety isn't
: ^^^^^^^^^^^^^^^^^^^
: ^^^^^
2 | necessary at all.
: ^^^^^^^^^^^^^^^^^
: ^^^|^^^^^^^^^^^^
: | |
: | `-- especially this part
: `----- I don't like this statement
`----
Colored output would make the various spans a lot clearer when things get more complex. 😄 Any thoughts on these examples?
from miette.
I think your last example might be my favorite honestly. I think it's pretty doable too.
Do you wanna give it a shot? I'm happy to give pointers!
from miette.
Related Issues (20)
- forward() attribute undocumented HOT 1
- Thiserror W/ Miette how to display? HOT 3
- Implement SourceSpan as a trait HOT 4
- Unclear which part of long lines is being pointed to HOT 1
- Change `link` label to something else HOT 1
- New Crates.io Release? HOT 3
- Potentially broken word wrapping on `main` HOT 3
- Update owo-colors to v4? HOT 5
- Can't get `syntect-highlighter` to work HOT 3
- Remove severity from diagnostic output HOT 1
- Add `UnwrapPretty` trait HOT 5
- Compile to wasm32-unknown-unknown / Compile without `terminal_size` HOT 4
- Errors with zero-length span and no context lines are mostly pointless HOT 1
- 要是错误提示能使用中文输出就好了! HOT 5
- Failing tests with `--all-features` HOT 1
- Feature request: output an error as `json::Value` or `serde_json::Value` directly HOT 2
- Feature request: Span line limit for diagnostics HOT 3
- Help: Sub Errors HOT 3
- Is there a reason that `Report` doesn't implement `Error` and `Diagnostic`? HOT 2
- Converting a `Report` to a `Box<dyn Diagnostic>` wipes all `Diagnostic` information HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from miette.