Skip to content

Syntax highlighting in module not working until module is declared #1840

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

Closed
Geobert opened this issue Sep 13, 2019 · 6 comments
Closed

Syntax highlighting in module not working until module is declared #1840

Geobert opened this issue Sep 13, 2019 · 6 comments
Labels
S-actionable Someone could pick this issue up and work on it right now

Comments

@Geobert
Copy link
Contributor

Geobert commented Sep 13, 2019

While working on #1730

I noticed highlight does not fully work on this code:

use hir::db::HirDatabase;
use ra_syntax::{
    ast,
    ast::{AstNode, AstToken, Literal},
    TextUnit,
};

use crate::{Assist, AssistCtx, AssistId};

pub(crate) fn make_raw_string(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
    let string = ctx.node_at_offset::<Literal>()?;
    None // I put that just to be sure that mismatch type was not causing the issue
}

image

Type and enum variant are not coloured.

@Geobert
Copy link
Contributor Author

Geobert commented Sep 14, 2019

It began to be highlighted once the file has been included in lib.rs

@ice1000
Copy link
Contributor

ice1000 commented Oct 10, 2019

It began to be highlighted once the file has been included in lib.rs

Therefore I'd say it's the expected behavior.

@matklad
Copy link
Member

matklad commented Oct 10, 2019

I think it makes sense to be more resilient about handing modules like this...

@Geobert
Copy link
Contributor Author

Geobert commented Oct 10, 2019

Therefore I'd say it's the expected behavior.

I understand what you're saying, but from a UX point of view, I don't think it's pleasant. IMO, this falls in error tolerance category

@ice1000
Copy link
Contributor

ice1000 commented Oct 10, 2019

Ok

@Geobert Geobert changed the title Syntax highlighting half broken Syntax highlighting in module not working until module is declared Oct 30, 2019
@lnicola lnicola added the S-actionable Someone could pick this issue up and work on it right now label Dec 21, 2020
@jonas-schievink
Copy link
Contributor

This is now diagnosed with a quick fix to add the right mod declaration, so closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

No branches or pull requests

5 participants