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

Add warning about unmerged diffs and fix diff logic #1027

Merged
merged 2 commits into from
Jan 8, 2024
Merged

Add warning about unmerged diffs and fix diff logic #1027

merged 2 commits into from
Jan 8, 2024

Conversation

jmthomas
Copy link
Member

@jmthomas jmthomas commented Jan 8, 2024

closes #1015

@jmthomas jmthomas requested a review from ryanmelt January 8, 2024 21:31
Copy link

codecov bot commented Jan 8, 2024

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (6a984be) 75.41% compared to head (1de4840) 75.35%.
Report is 34 commits behind head on main.

Files Patch % Lines
...ges/openc3-cosmos-ace-diff/src/diff-match-patch.js 0.00% 2 Missing ⚠️
...ugins/packages/openc3-cosmos-ace-diff/src/index.js 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1027      +/-   ##
==========================================
- Coverage   75.41%   75.35%   -0.07%     
==========================================
  Files         589      590       +1     
  Lines       42806    43119     +313     
  Branches      747      749       +2     
==========================================
+ Hits        32284    32491     +207     
- Misses      10444    10550     +106     
  Partials       78       78              
Flag Coverage Δ
frontend 55.28% <0.00%> (+0.28%) ⬆️
python 83.63% <ø> (-0.39%) ⬇️
ruby-api 48.71% <ø> (+0.01%) ⬆️
ruby-backend 80.45% <ø> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

diffs_b
)
}
// JMT: This doesn't always return a good result so commenting it out
Copy link
Member Author

Choose a reason for hiding this comment

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

Near as I can tell this was just an optimization

// algorithm shifts left to include the leading newline.
if (equality1[equality1.length - commonOffset] === '\n') {
commonOffset -= 1
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This is what was breaking the common diff use case of inserting a line. A diff of added code\n became \nadded code

// because when it is inserted the first one is effectively eaten
// by the replace and merging of the lines
if (i === startLine && contentToInsert === '') {
// However if the targetStartLine is the very top then we don't
if (i === startLine && contentToInsert === '' && targetStartLine != 0) {
contentToInsert += '\n'
Copy link
Member Author

Choose a reason for hiding this comment

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

I think I added this a while ago and while it's needed in some cases it doesn't work if inserting at the very top.

Copy link

sonarqubecloud bot commented Jan 8, 2024

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

1 New issue
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@jmthomas jmthomas merged commit f36ec09 into main Jan 8, 2024
24 checks passed
@jmthomas jmthomas deleted the diffs branch January 8, 2024 23:38
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

Successfully merging this pull request may close these issues.

Add Are you Sure when diffs aren't incorporated in plugin upgrade
2 participants