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

Unexpected line diffs when a code block is inserted after a previous difference #109

Open
vsquared56 opened this issue Jul 18, 2023 · 0 comments

Comments

@vsquared56
Copy link

Hi, thanks for this project! I noticed the following issue which may come up when, for example, entire code blocks are inserted.

Consider these two simple .js files:

File1:

function foo() {
    console.log("foo");
}

File2:

function foo() {
    console.log("foo");
}

function bar() {
    console.log("bar");
}

Here, the line-level diff is expected, it's clear that all of bar() was inserted, along with its end brace:
image

Now, consider a similar addition, but with a simple change inside foo():

File3:

function foo() {
    bar();
    console.log("foo");
}

function bar() {
    console.log("bar");
}

image

Comparing File1 with File3 shows the change begins at the end brace of foo(), and it's not immediately clear that a complete function was added.

Worth noting that this matches the behavior of GNU diff:
image

But tools like DiffChecker.com give output that is potentially more useful:
image

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

1 participant