dmsnell / diff-match-patch

Diff Match Patch is a high-performance library in multiple languages that manipulates plain text.
Apache License 2.0
23 stars 5 forks source link

Tracking Issue: Remove index/count confusion. #4

Open dmsnell opened 8 months ago

dmsnell commented 8 months ago

When diffs report deleted or equivalent characters they report a span length as a count of characters; unfortunately there is no common definition of character.

diff-match-patch could resolve this in a backwards-compatible way by adding a preamble to its patches that indicates which definition is in use, through the use of semantically empty diff groups.

For example, a leading group of zero length or an empty insert operation should have no impact on the diffed files, so may be used to communicate very small amounts of information.

Consider:

A new parameter to the diffing functions can set a mode so that clients can request specific counts. For example, diff_main(a, b, {units: 'unicode'})