Limit the context shown in changed outputs à la git-diff
Opened this issue · 0 comments
Currently, if the "outputs" for a cell contain a change, nbdime shows the entire list of outputs for both, even if the change is small and the full list of outputs large. This can result in large areas of unchanged text. See the screenshot below, which shows a simplified example containing eight output items preceding a deleted output item (though imagine this being 100 hundred items).
It would be better if nbdime used e.g. Git's approach of showing a limited and/or configurable amount of context. For example, git-diff
has the --unified=<n>
option, which "Generate[s] diffs with lines of context instead of the usual three."
In nbdime's case, it could for starters use individual items in the "outputs" list as a stand-in for lines (as the "outputs" key-value is a list of output items), as opposed to individual lines within each output item. (The latter could be a more advanced approach considered later.)
![Screen Shot 2024-02-06 at 10 21 44 AM](https://private-user-images.githubusercontent.com/355822/302737418-ab7ac118-f4aa-4eb9-ad6e-5ec2f8882038.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk3NjA4NjIsIm5iZiI6MTczOTc2MDU2MiwicGF0aCI6Ii8zNTU4MjIvMzAyNzM3NDE4LWFiN2FjMTE4LWY0YWEtNGViOS1hZDZlLTVlYzJmODg4MjAzOC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjE3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxN1QwMjQ5MjJaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1jNTBlZmE2YjU0MDAwMTAwZjlmZTU3ZTkwMDhhOWVlMjNhMmRjMjJmYTQ3Njk2ZDFiNDMwNGY4ODg0YjQ2Mzk3JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.jz2n2_3dqSj9pMSXw-p5sIEKt13cOJP5AYhXo_qgnqo)
In this example, the json looks like this (excerpt):
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"AAA\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"AAA\n"
]
},
...