Skip to content

Add textdiff.Replacement to support range-based edits as in Go's analysis.TextEdit. #24

@jschaf

Description

@jschaf

Hi, first off: this is a really nice library. It's a pleasure reading to read through the source code and accompanying blog post.

Context

I'd like to use this library to manage diffs for a meta-linter. Many linters emit fixes as range-based replacements rather than as diffs, like so:

{"start": 10, "end": 20, "replacement": "foo bar"}

To convert the replacements into a diff for display and patching, I've implemented similar logic as textdiff.

Feature requests

  • FR1: Add textdiff.Replacement to natively support range-based edits.
  • FR2: Add a conversion function from []textdiff.Replacement to []textdiff.Hunk.
  • FR3: Generalize to diff. This is a nice-to-have since I don't need it, but it seems helpful to maintain parity with textdiff.

References

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