Problem/Motivation
The unified fields got line numbers.
I fear that the Strip Tags filter could change line numbers.
Proposed resolution
We need to check if line numbers are preserved.
If not, we should better remove the line numbers when applying that filter.
Or we could split source by newline and run split_tags per line.
This however would break tags that are spread across multiple tags.
Changes are, that at least if a tag is multiline, the lines are dropped.
I would add test coverage and decide for a simple solution here.
In a follow-up we can discuss if there is a way to implement strip_tags on our own with preserving line numbers.
User interface changes
Only show line numbers if they are correct.
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | hide_line_numbers-2802835-18.patch | 4.55 KB | ginovski |
| #18 | interdiff-2802835-16-18.txt | 675 bytes | ginovski |
| #16 | hide_line_numbers-2802835-16.patch | 4.81 KB | ginovski |
| #14 | hide_line_numbers-2802835-13.patch | 7.99 KB | ginovski |
| #14 | interdiff-2802835-7-13.txt | 7.96 KB | ginovski |
Comments
Comment #2
johnchqueSince striping tags divide the text in multiple times it sometimes hide some lines that haven't changed, thus the line numbers change. I would vote for removing them when striping tags.
Comment #3
miro_dietikerLike i proposed:
We hide it in this issue, because we know about the problem.
Then we open a follow-up to implement a workaround that guarantees the line number stability. We can do this, but it's a larger issue.
Comment #4
ginovski commentedAdded a flag $strip_tags_active, and checking for it when adding line numbers.
Screenshot provided.
Comment #5
tduong commentedLooks fine, even though ...
... I'm not sure if php explicitly needs "()" for this kind of if-statement
Then although in the proposed solution is written:
the simple solution is more or less defined, but we still need a test I guess.
Comment #6
miro_dietiker@tduong See PHP Operator Precedence, yes this works.
http://php.net/manual/en/language.operators.precedence.php
I'm not a big fan of those complex && ! ? : and they are often source of unexpected behavior...
I'm asking myself what $show means (better variable name?) and if we should negate the second such as $raw_active.
BTW Why is this $show not applicable to the right side?
Comment #7
ginovski commented$show is from another issue #2793029, it is used to show the same line number on both columns if the line is the same for both revisions.
It compares the line from both revisions, and if they are the same, the left column has its own line number, and the right is increased by 1.
If $show doesn't apply, then only the left column shows the right number of the line, and the right column would be either empty or showing wrong number.
1. I added a test coverage in the DiffRevisionTest, asserting that the line numbers columns are empty.
2. Renamed the variable from strip_tags_active to raw_active and changed usage properly.
I am not sure whether I should remove both columns when 'strip_tags' filter is applied, or keep them empty like this?
Comment #8
johnchqueI would vote to remove the columns completely. :)
Comment #9
miro_dietikerYeah. It moves columns around, but definitively, remove them.
Don't forget to adjust the headers.
Comment #10
ginovski commentedAdded 2 ways to remove the columns:
1. if/else
2. array_slice with a helper $row_counter.
I think 2. seems more clean.
Comment #13
miro_dietikerYou implicitly expect that the index $row_counter is identical to what was used before. If you introduce such a key, you will need to use it everywhere (replace []).
array_slice lacks two spaces after comma.
Also as i reminded in #9, you only modify table content rows, not the headings.
So yeah, slicing seems to work well here.
We could also simply switch to named column keys, like i proposed in #2785857: Introduce header / row table keys - then using conditional unset() would be very easy.
Comment #14
ginovski commentedForgot to configure the tests in the last patch, ignore #10.
Now I added:
1. If/else condition to write/not write first 2 columns with line numbers
2. Configured the test functions properly.
Comment #16
ginovski commentedOkay, now with array_slice, ignore #14.
1. Configured tests.
2. Added $row_counter as index in the array
3. In the header I only changed the colspan,
Comment #18
ginovski commentedReversed small mistake, should be ok now.
Comment #19
johnchquewow looks nice now. btw #2800155: Flood of warnings after updating to Diff 8.x-1.0-alpha5 should go in first. :)
Comment #21
miro_dietikerRebased, worked. Committed.
And added some comment about what the code is doing.