Skip to content

Invalid patch highlighting for indented code #405

Description

@0x2a-42

I noticed in my Lua linter, that the highlighting of patches is wrong, if the code is indented. It works correctly if the code is not indented.

do
  local function f()
    print()
  end
end
Image

Here is a minimal reproducer.

use annotate_snippets::{Group, Level, Patch, Renderer, Snippet};

fn main() {
    let source = "do\n  local function f()\n    print()\n  end\nend\n";
    let delete_span = 5..41;
    let group = Group::with_title(Level::HELP.secondary_title("delete the definition"))
        .element(Snippet::source(source).patch(Patch::new(delete_span, "")));
    let renderer = Renderer::styled();
    println!("{}", renderer.render(&[group]));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions