- Change Summary:
-
As soon as I hit Publish Changes I found a glitch when viewing expanded reviews, due to my misuse of the CSS visibility status. This is a fix, tested in Safari 4 and Firefox 3.5.
- Diff:
-
Revision 2 (+94 -8)
Toggling of the display of whitespace-only changes.
Review Request #899 — Created June 18, 2009 and submitted
This patch adds a basic infrastructure to adding metadata to diff in a line/chunk/file level. It also implements the detection of whitespace-only changes in diff, and adds a button to the diff viewer to toggle between whitespace visible and highlighted, or hidden and regular. As a design decision I choose not to collapse a chunk that consisted only of whitespace changes, as it would create an inconsistency with chunks that mix both whitespace and regular changes. For mixed chunks, the lines that contain only whitespace are set to the regular background, making the visualization better. I also decided not to move the thin gray lines, that delimit a chunk, in cases of mixed chunks were the whitespace-only section was at the beginning or at the end, as I thought this could cause confusion to the user, to suddenly see a chunk shrink. For whole chunks, on the other hand, I thought it would be better to hide everything, an so I did. As all those decisions were pretty arbitrary, I'd really like some input about them. I also decided to post this patch without unit test for it, as then we can review while I do the unit testing.
Ran all unit tests currenly available, without a breakage. Applied patch in a production system, with no breakage of existing reviews. Tested on IE 7, Chrome, Firefox 3.5 and 3.0 and Safari 4.0. A Unit test for this is needed and will be provided in a following update.
-
-
I'd prefer if you could make another function that wraps diff_line and use it in the map() above. This way we only have to iterate through the lines once instead of twice.
-
-
-
-
-
-
And here's a 4th iteration, but this one is a generator. If you can fold all of these loops in together and keep the yield, it'll make it all much more efficient.
-
The way you're using this "num_whitespace_chunks" variable is very odd. It seems to be a negative count of non-whitespace chunks, from my reading. Here's how I'd write it: file['whitespace_only'] = True for j, chunk in enumerate(file['chunks']): chunk['index'] = j if chunk['change'] != 'equal': file['changed_chunks'].append(chunk) if not chunk['meta'].get('whitespace_chunk', False): file['whitespace_only'] = False
-
-
-
-
-
-
-
-
Space after the : Also, on the comments, there should be a space after #, and the comment should end with a period.
-
-
-
-
Since we reference table.sidebyside instances many times, we should store the result of $("table.sidebyside") in a variable and reference that variable for all other uses.
-
-
-
-
Rather than having onclick, I'd prefer that diffviewer.js register these actions for these links. You can give them IDs to reference them.
- Change Summary:
-
Made all changes suggested by Christian, except the yielding one, as I consider it necessary for future work.
- Diff:
-
Revision 5 (+117 -8)
- Change Summary:
-
Made the changes requested by David, about moving the compilation to outside of the loop.
- Diff:
-
Revision 6 (+118 -8)