Skip to content

🐛 rg --json syntax highlighting around comments incorrect for Python #1876

@dandavison

Description

@dandavison

If we take this Rust code:

z.rs

// this is a comment
let x = "this is code";

and this Python code:

z.py

# this is a comment
x = "this is code"

Then delta's rg --json handling correctly highlights the Rust:
image

But is incorrect for Python: the syntax highlighting state incorrectly remains in comment mode on the second line:
image

I'm not sure if this is a bug in syntect or delta. I notice that in grep.rs our line of code does not have a terminal \n; adding this (with push('\n') in ripgrep_json.rs) fixes the issue superficially, but if the user has requested multiple context lines then it introduces undesired extra blank lines.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions