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

Panic with class highlighter #336

Closed
Keats opened this issue Jun 21, 2021 · 3 comments
Closed

Panic with class highlighter #336

Keats opened this issue Jun 21, 2021 · 3 comments

Comments

@Keats
Copy link
Contributor

Keats commented Jun 21, 2021

To reproduce:

  1. Update sublime package subrepo to 207cf862
  2. Run the following test:
    #[test]
    fn test_classed_html_generator_panics() {
        let current_code = "{\n    \"headers\": [\"Number\", \"Title\"],\n    \"records\": [\n        [\"1\", \"Gutenberg\"],\n        [\"2\", \"Printing\"]\n    ],\n}\n";
        let syntax_set = SyntaxSet::load_defaults_newlines();
        let syntax = syntax_set.find_syntax_by_token("json").unwrap();
        println!("{:?}", syntax);
        let mut html_generator = ClassedHTMLGenerator::new_with_class_style(&syntax, &syntax_set, ClassStyle::Spaced);
        for line in LinesWithEndings::from(current_code) {
            html_generator.parse_html_for_line_which_includes_newline(&line);
        }
        let html = html_generator.finalize();
        assert_eq!(html, "<span class=\"source r\">x <span class=\"keyword operator arithmetic r\">+</span> y\n</span>");
    }

It will panic with:

thread 'html::tests::test_classed_html_generator_panics' panicked at 'tried to restore cleared scopes, but none were cleared', src/parsing/scope.rs:450:29

Making src/parsing/scope.rs:450:29 a no-op (() instead of panicking) fixes the issue and it seems highlighted correctly (?).

@keith-hall
Copy link
Collaborator

Thanks for reporting. I believe my comment/diagnosis at #326 (comment) applies here.

@Keats
Copy link
Contributor Author

Keats commented Jun 22, 2021

PR: #337

@Enselic
Copy link
Collaborator

Enselic commented Nov 9, 2021

Closed by the merged PR #337

@Enselic Enselic closed this as completed Nov 9, 2021
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

No branches or pull requests

3 participants