Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight text pointed to by labels #206

Closed
dtolnay opened this issue Mar 18, 2020 · 4 comments · Fixed by #253
Closed

Highlight text pointed to by labels #206

dtolnay opened this issue Mar 18, 2020 · 4 comments · Fixed by #253

Comments

@dtolnay
Copy link
Contributor

dtolnay commented Mar 18, 2020

I noticed that codespan-reporting 0.9 is no longer highlighting the file characters pointed to by labels. For my use case I think I found that the highlighted way was preferable. Is this something that you would be open to bringing back as an option?


codespan-reporting 0.8.0:

Screenshot from 2020-03-18 15-00-30

codespan-reporting 0.9.0:

Screenshot from 2020-03-18 14-58-02

@jyn514
Copy link
Collaborator

jyn514 commented Mar 18, 2020

Relevant PR: #168

@jyn514
Copy link
Collaborator

jyn514 commented Mar 18, 2020

Maybe #100 and highlighting text could be made mutually exclusive? That would look a little odd visually anyway.

@brendanzab
Copy link
Owner

Yeah, I'm currently in the process of trying to implement #100, and the highlighted code sections were rather hard to deal with - ie. you need to figure out which to prioiritise (perhaps primary spans?).

As an aside I've also noticed that the diagnostics begin to look super over-bearing when multiline source code is highlighted in colour.

@brendanzab
Copy link
Owner

brendanzab commented Jun 21, 2020

Had another look at this today. This is the relevant part of the code that we'd need to change:

// Write source
write!(self.config.source(self.writer), " {}", source)?;
write!(self, "\n")?;

Sketching it out, it might look something like this:

// Write source text
write!(self, " ")?;
for (byte_index, ch) in source.char_indices() {
    // TODO: Check if in primary multi-line label
    // TODO: Check if in primary single-line label
    // TODO: Do tab-stop calculation here, rather than using `self.config.source(self.writer)`
    write!(self, "{}", ch)?;
}
// TODO: undo styling if necessary
write!(self, "\n")?;

I'm thinking we'd only highlight primary labels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants