381: Some comment flags not visible in diff view

markd*****@gmai***** (Google Code) (Is this you? Claim this profile.)
Feb. 10, 2009
Some comment flags are not shown for some lines in the diff.  If the
comment dialog is shown (by clicking on the line where comments are known
to exist), then the comment flag will appear, with the correct number of
comments.

Based on stepping through the javascript, the problem seems to occur when
the number of hidden lines is greater than the number of lines showing, and
the comment is left in the first half of the diff. 

More precisely, the comment flags are added by addCommentFlags in
diffviewer.js.  That routine calls findLineNumRow to get the row
corresponding to the file's line number.

Around line 493, findLineNumRow (svn rev 1151), there is this code:
    for (var i = Math.round((low + high) / 2); low < high - 1;) {
        row = table.rows[row_offset + i];

        if (!row) {
            high--;
            continue;
        }

The starting values: low = 1, high = 1257, and table.rows has 607 elements.
So i is 629, and it appears this loop will terminate before finding a row
in the table.

The problem may also be with setting the initial conditions in the previous
block.

    if (row != null) {
        /*
         * We collapsed the rows (unless someone mucked with the DB),
         * so the desired row is less than the row number retrieved.
         */
        high = parseInt(row.getAttribute('line'))
    }

The value of 'high' gets set to a file line number rather than an index
into table.rows.
#1 segueto*******@gmai***** (Google Code) (Is this you? Claim this profile.)
as a workaround we found that clicking the "expand changes" link in the header box
will display the missing comments
chipx86
#2 chipx86
  • +Component-DiffViewer
david
#3 david
Christian, is this applicable to the UI rewrite.
david
#4 david
This code has been completely rewritten. 
  • +Fixed