Skip to content

Textmate grammar: prevent early termination of raw strings with hash (closes #6042) #6248

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

Merged
merged 1 commit into from
Oct 17, 2020

Conversation

dustypomerleau
Copy link
Contributor

@dustypomerleau dustypomerleau commented Oct 16, 2020

Problematic sample code from #6042:

#[derive(Debug, Clone, Logos)]
enum Quoted<'source> {
    #[regex(r#"[^\\"']+"#)]
    Text(&'source str),
    #[token("\\")]
    StartEscape,
    #[token("\'", |_| Quote::Single)]
    #[token("\"", |_| Quote::Double)]
    End(Quote),

    #[error]
    Error,
}

Before fix:

Screen Shot 2020-10-16 at 10 45 59

After fix:

Screen Shot 2020-10-16 at 10 45 33

@dustypomerleau dustypomerleau changed the title prevent early termination of raw strings with hash (closes #6042) Textmate grammar: prevent early termination of raw strings with hash (closes #6042) Oct 16, 2020
@matklad
Copy link
Member

matklad commented Oct 17, 2020

bors r+

@bors
Copy link
Contributor

bors bot commented Oct 17, 2020

@bors bors bot merged commit 63956e5 into rust-lang:master Oct 17, 2020
@matklad
Copy link
Member

matklad commented Oct 17, 2020

Seems like there are still some problems with strings:

image

(in this file: https://github.com/matklad/xshell/blob/ef3b40601bfd758ce290cc54168729536365eb20/tests/it.rs#L276)

I've noticed that this is pretty sever -- vscode classify code as string literals, which disables completion popup and probably many other featurs.

@matklad
Copy link
Member

matklad commented Oct 17, 2020

(I think I am running extension with this pathc applied, but tis better to doublehcekc)

@dustypomerleau
Copy link
Contributor Author

I'm not at my machine, but it looks like that opening curly is starting an interpolation scope, which continues past the end of the string because there's no closing curly.

Will fix.

@dustypomerleau dustypomerleau deleted the raw branch October 18, 2020 02:21
bors bot added a commit that referenced this pull request Oct 18, 2020
6275: Textmate grammar: prevent unwanted interpolation scopes r=matklad a=dustypomerleau

Fixes the issues noted by @matklad after merging #6248. 

1. prevent accidental interpolation scopes when `{` is used in a string
1. prevent interpolations from extending beyond the end of a string

Co-authored-by: Dusty Pomerleau <[email protected]>
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 this pull request may close these issues.

3 participants