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

[WIP] Preliminary prototype for collapsed output #55

Open
TheWebDevel opened this issue Jun 30, 2020 · 12 comments
Open

[WIP] Preliminary prototype for collapsed output #55

TheWebDevel opened this issue Jun 30, 2020 · 12 comments

Comments

@TheWebDevel
Copy link
Contributor

TheWebDevel commented Jun 30, 2020

Usecase: Difference between two structs.
Assertion: assert_equal

Current Output:
image

Collapsed Output:
image

Method: String Iteration

Implementation:

  1. Computed the index of each occurrence with reference to (- or +). // [4, 5, 16, 17, 20, 21]
  2. I have a cur_index and a peek_index.
  3. If the difference between cur_index and peek_index is <= 5, I'll have those index and the intermediate values in the final collapsed output else I have a .... // [4, 5, 16, 17, 18, 19, 20, 21]
@aaronabramov
Copy link
Owner

might wanna have some more context around the changes and some hints around how much you skipped:

  A { 
    a: "Kelly"
... 20 lines hidden
    b: "blah blah"
-   c: 1
+   c: 2
    d: 4
... 20 lines hidden
}

@aaronabramov
Copy link
Owner

also. for the algorithm you probably want to do it at the same time you're constructing by keeping the unchanged_count counter as you're iterating through the diff, so you do everything in one pass.
you might need some lookahead for that

@TheWebDevel
Copy link
Contributor Author

Yeah! I'm planning to do those things as well. As I said, this is a prelim first implementation prototype. I'll do that and let you know. :D Thanks!!

@TheWebDevel
Copy link
Contributor Author

TheWebDevel commented Jul 1, 2020

Sure. I'll optimize the approach. So, can I proceed with the lookahead approach and extend it? I'll reply to this thread with the outcome of this ASAP. :D

@aaronabramov
Copy link
Owner

also, we should probably have some threshold. if i'ts lass than 30 lines we don't collapse anything

@TheWebDevel
Copy link
Contributor Author

Yeah!

@TheWebDevel
Copy link
Contributor Author

Update:

I found a way to collapse the output with single iteration.(Sorry about the colors, Need to find a way to put em back :P)
image

Currently working on adding context to the diff. :))

@TheWebDevel
Copy link
Contributor Author

Ok, I integrated colored_diff with my logic for collapsing large output. It's so far so good.

What'll I do next?

  1. Going to write a lot of test cases.
  2. If all good, Implement into the library as a feature and submit for review

Here are some of the results:
Struct diff
image

Vector diff
image

Thanks, @aaronabramov :D

@aaronabramov
Copy link
Owner

aaronabramov commented Jul 9, 2020

you might want some padding/context around changed lines!

right now you have

- 20
+ 3
... 10 lines collapsed

you probably want

- 20
+ 3
  4 // unchanged line
  5 // unchanged line
... 10 lines collapsed

@aaronabramov
Copy link
Owner

also need to find a good way to distinguish ... 10 lines collapsed from the acutual content. they're both grayed out right now :)

@TheWebDevel
Copy link
Contributor Author

Noted! :D

@TheWebDevel
Copy link
Contributor Author

PR: #61

@github-staff github-staff deleted a comment May 27, 2024
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

2 participants