Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: for issue-144 page hanging on large files#172

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
TristanSpeakEasy wants to merge1 commit intopraneshr:master
base:master
Choose a base branch
Loading
fromspeakeasy-api:issue-144

Conversation

@TristanSpeakEasy
Copy link

fix for#144

@kamaldlk
Copy link

pls merge this, most wanted for me

@erothmayer
Copy link

This codeshould not be used. It is faster, but it is incorrect.

Because the new approach is "chunking" the diff processing into sets of 100 it gives incorrect results on inputs over 100 lines long. For example, you can use the following inputs to simulate a pair of input files 302 lines long where the only difference is that a single line has been removed from the new value.

const range = (start, end) => [...Array(end).keys()].slice(start, end);const oldValue = `{\n${range(0, 300).join('\n')}\n}`;const newValue = `{\n${[...range(0, 50), ...range(51, 300)].join('\n')}\n}`;

When I try this in the original version of the code it works fine, and reports only the line containing "50" as removed and no other changes. When I try it with the suggested change above it correctly reports the line containing "50" as removed on the left, but then reports the lines containing "99", "149", "199", "249", and "299" as removed on the left and added on the right.

This problem will become worse the larger the difference in line counts between the files. Once you get past 100 lines difference on a given side,every line will be reported as a difference even when all the lines exist with no changes elsewhere in each file.

Comment on lines +169 to +184
letoa=oldArr.splice(0,num);
letna=newArr.splice(0,num);

while(oa.length>0||na.length>0){
consto=oa.join("");
constn=na.join("");
diffArray=diffArray.concat(
diff.diffLines(o,n,{
newlineIsToken:true,
ignoreWhitespace:false,
ignoreCase:false,
})
);
oa=oldArr.splice(0,num);
na=newArr.splice(0,num);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This approach causes the result to be incorrect. Because you're chunking the call todiffLines into units of 100 lines additions or deletions will cause equal lines to get pushed into different chunks, where the underlying diff algorithm can no longer match them up.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

2 more reviewers

@erothmayererothmayererothmayer left review comments

@kamaldlkkamaldlkkamaldlk approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@TristanSpeakEasy@kamaldlk@erothmayer

[8]ページ先頭

©2009-2025 Movatter.jp