80- (or n-) column indicator in diff viewer
Review Request #11294 — Created Nov. 20, 2020 and updated
The current diff viewer does not have a column indicator that shows
the character boundary. Adding the feature will allow reviewers to see
when a line exceeds n characters.We added a red dashed line on the diff viewer at the specified column.
The indicator defaults to 80 characters and the user can specify a
number at the input box on top. With file changes, the indicator shows
on both side of the diff viewer and changes together. We also check
for the maximum column number based on the diff viewer's size. If the
diff viewer is shrunk beyond the indicator, the indicator will be
hidden.We added the indicator as a
div
which the CSS property
border-left: 1px dashed red
. Whenever the column number is changed,
moveColumnIndicator()
does the calculation and moves the indicator
to the new position with jQuery'scss()
. Although JS function does
the calculations everytime the position changes, in theory, a user
will not be changing the position too often.Testing Done:
Tested following behaviours:
- Set column indicator to 0 (check underflow)
- Set column indicator to 999 (check overflow)
- Check indicator line
Browsers tested:
- Chrome (Version 87.0.4280)
- Edge (Version 87.0.664.5)
- Firefox (Version 83.0)
- Safari (Version 14.0.1)
Tested following behaviours:
- Set column indicator to 0 (check underflow)
- Set column indicator to 999 (check overflow)
- Check indicator line
Browsers tested:
- Chrome (Version 87.0.4280)
- Edge (Version 87.0.664.5)
- Firefox (Version 83.0)
- Safari (Version 14.0.1)
Summary | |
---|---|
Description | From | Last Updated |
---|---|---|
I tried hosting the patched server on my local machine and the column indicator looks great! I agree with Jacob … |
|
|
It looks like some lines in the description are longer than the format expected. Could you target ~70 (upwards of … |
|
|
When referencing a JavaScript method in the docs, you'll want to use the js:meth: role, like: :js:meth:`_moveColumnIndicator` Same with docs … |
|
|
Rather than var, this should use const. Or just pass the expression into the call that needs it. I would … |
|
|
You can define these where they're needed. Either const or let should be used instead of var, depending on whether … |
|
|
Let's use .text(), to better communicate that we're not inserting HTML. |
|
|
Where does this number come from? |
|
|
Blank line between statements that form blocks. |
|
|
The - operator should go on the previous line, and each line of the expression should be aligned. |
|
|
Each parameter to Math.min() should be aligned. |
|
|
You can use template literals here and above: `translateX(${columnNum * charWidth}px)` |
|
Commits: |
|
||||||||
---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 2 (+70 -2) |
Checks run (2 succeeded)
Change Summary:
Add Description.
Description: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Commits: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
Groups: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
Diff: |
Revision 3 (+251 -33) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added Files: |
Checks run (2 succeeded)
Change Summary:
Clean up commits.
Testing Done: |
|
||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Commits: |
|
||||||||||||||||||||||||||||||||||||
Diff: |
Revision 4 (+222 -4) |
Checks run (2 succeeded)
-
-
reviewboard/static/rb/js/diffviewer/views/diffReviewableView.es6.js (Diff revision 4) When referencing a JavaScript method in the docs, you'll want to use the
js:meth:
role, like::js:meth:`_moveColumnIndicator`
Same with docs below.
-
reviewboard/static/rb/js/diffviewer/views/diffReviewableView.es6.js (Diff revision 4) Rather than
var
, this should useconst
. Or just pass the expression into the call that needs it.I would rework this to properly use the chaining syntax:
cons newColumnNum = this.$el .find('....') .val()
That's often used with jQuery, and it helps make each step in the chain clear.
-
reviewboard/static/rb/js/diffviewer/views/diffReviewableView.es6.js (Diff revision 4) You can define these where they're needed. Either
const
orlet
should be used instead ofvar
, depending on whether the variable needs to be reassigned. -
reviewboard/static/rb/js/diffviewer/views/diffReviewableView.es6.js (Diff revision 4) Let's use
.text()
, to better communicate that we're not inserting HTML. -
reviewboard/static/rb/js/diffviewer/views/diffReviewableView.es6.js (Diff revision 4) Where does this number come from?
-
reviewboard/static/rb/js/diffviewer/views/diffReviewableView.es6.js (Diff revision 4) Blank line between statements that form blocks.
-
reviewboard/static/rb/js/diffviewer/views/diffReviewableView.es6.js (Diff revision 4) The
-
operator should go on the previous line, and each line of the expression should be aligned. -
reviewboard/static/rb/js/diffviewer/views/diffReviewableView.es6.js (Diff revision 4) Each parameter to
Math.min()
should be aligned. -
reviewboard/static/rb/js/diffviewer/views/diffReviewableView.es6.js (Diff revision 4) You can use template literals here and above:
`translateX(${columnNum * charWidth}px)`
Change Summary:
Address feedback (fix styling).
Commits: |
|
|||||||||
---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 5 (+234 -4) |
Checks run (2 succeeded)

-
I pulled down the patch, ran it locally, and it works great. Awesome work Kean! Not sure that I am too familiar with the code, so I will comment mostly on my user experience. Firstly, I noticed that the column indicator input text can overlap with the New File Download button if set to 0, this could be annoying especially for users that are uninterested in seeing the column indicator. In addition, I think that it could be useful to have a toggle button on the indicator to turn it on/off and give users more flexibility. I also noticed that the input field works with hexadecimal numbers such as
0xf
, not sure if that is the intended behavior. But it's kind of cool nonetheless.
-
-
I tried hosting the patched server on my local machine and the column indicator looks great!
I agree with Jacob on the part when user sets the column indicator to around 5, the indicator overlaps with the text below it.
Also, I tested the diff viewer on both Chrome Version 86 and Safari 14. The indicator works perfectly on Chrome but on Safari, the indicator text box does not align with the indicator line, I've attached a picture below. This only happends when you first load the page and if you set it to something else and set it back later, the text box does align with the line indicator.
Change Summary:
Change input box to fixed position and update screenshot. (details)
Commits: |
|
|||||||||
---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 6 (+194 -4) |
|||||||||
Added Files: |
Checks run (2 succeeded)
Change Summary:
Update description to wrap at 70 columns.
Description: |
|
---|
Change Summary:
Update description.
Description: |
|
---|