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

How to show diff across two panes #201

Closed
techwizardg opened this issue Oct 9, 2017 · 2 comments
Closed

How to show diff across two panes #201

techwizardg opened this issue Oct 9, 2017 · 2 comments

Comments

@techwizardg
Copy link

This is not an issue but wanting to know how to achieve the same. We would like to show the diff between two files in two panes(i.e. like what we see in win merge with colour code to indicate if added or removed) and is this possible and if so if you could guide me to do the same it would be appreciated.

@wangzuo
Copy link

wangzuo commented Oct 11, 2017

You may create a patch with jsdiff and use something like parse-diff to parse it again. I am not sure jsdiff has built-in support for this.

@ExplodingCabbage
Copy link
Collaborator

I would think you'd want to do something along these lines:

  1. print change objects representing preserved sections (i.e. ones where added and removed are both falsey) in both panes, with no background color
  2. when you reach a sequence of change objects representing additions or removals, print the removals in the left pane with red background color, and the additions in the right pane with green background color, keeping track of how many you've printed, until you reach the next preserved section. Then add empty lines to whichever pane is shorter until the panes contain the same number of lines, and go to step 1.

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

3 participants