Wyatt Allen 659f15110f Correct logic for matching a new comment to its thread in a group
When a new comment is being added to a line, Gerrit checks to see if
there is an existing thread on the same line (and same range, if any) so
that the comment can be appended to it if so. Otherwise, a new thread is
created.

However, following I4f7804ac02, the logic to identify the appropriate
thread by range was refactored to not use range location strings, but
use range objects instead. Problematically, there were two flaws in this
code:
1)  The range object references were compared rather than their values.
2)  Only new threads were being rendered with their corresponding ranges
    whereas existing threads were not.

As a result, if the user attempted to add a line comment on a line with
an existing ranged comment, the ranged comment's thread would be
identified as the destination (because the new comment has no range and
the existing thread's range was not being set). Appending the range-less
comment to a ranged thread resulted in incoherent data and the draft
would be unsavable.

With this change, the logic uses value equality to match ranges and the
`gr-diff-comment-thread-group#_getThreads` method is updated to set the
range on existing threads.

Bug: Issue 8410
Change-Id: If34e0d46a5c1af81bec82125217088fb574a2f61
2018-02-21 21:51:56 +00:00
..