Fix inability to leave multiple comments on line of code
This appears to have broke in I0428fead7a9d1f1dc5d6aa9efc3d81ecbe6b5c64 The computation to get the comment thread used to pass the range object, but stopped doing so in the above change. This change adds it back in and also separates the range string computation so that additional unit tests can be added. Bug: Issue 7081 Change-Id: I846d0c24b894fa0577f4fefaf8dcf4fc751daa15
This commit is contained in:
@@ -313,7 +313,7 @@
|
||||
const isOnParent =
|
||||
this._getIsParentCommentByLineAndContent(lineEl, contentEl);
|
||||
const threadEl = this._getOrCreateThreadAtLineRange(contentEl, patchNum,
|
||||
side, isOnParent);
|
||||
side, isOnParent, opt_range);
|
||||
threadEl.addOrEditDraft(opt_lineNum, opt_range);
|
||||
},
|
||||
|
||||
@@ -325,6 +325,20 @@
|
||||
return contentEl.querySelector('gr-diff-comment-thread-group');
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} commentSide
|
||||
* @param {!Object=} opt_range
|
||||
*/
|
||||
_getRangeString(commentSide, opt_range) {
|
||||
return opt_range ?
|
||||
'range-' +
|
||||
opt_range.startLine + '-' +
|
||||
opt_range.startChar + '-' +
|
||||
opt_range.endLine + '-' +
|
||||
opt_range.endChar + '-' +
|
||||
commentSide : 'line-' + commentSide;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {!Object} contentEl
|
||||
* @param {number} patchNum
|
||||
@@ -334,13 +348,7 @@
|
||||
*/
|
||||
_getOrCreateThreadAtLineRange(contentEl, patchNum, commentSide,
|
||||
isOnParent, opt_range) {
|
||||
const rangeToCheck = opt_range ?
|
||||
'range-' +
|
||||
opt_range.startLine + '-' +
|
||||
opt_range.startChar + '-' +
|
||||
opt_range.endLine + '-' +
|
||||
opt_range.endChar + '-' +
|
||||
commentSide : 'line-' + commentSide;
|
||||
const rangeToCheck = this._getRangeString(commentSide, opt_range);
|
||||
|
||||
// Check if thread group exists.
|
||||
let threadGroupEl = this._getThreadGroupForLine(contentEl);
|
||||
|
||||
@@ -224,6 +224,20 @@ limitations under the License.
|
||||
});
|
||||
});
|
||||
|
||||
test('_getRangeString', () => {
|
||||
const side = 'PARENT';
|
||||
const range = {
|
||||
startLine: 1,
|
||||
startChar: 1,
|
||||
endLine: 1,
|
||||
endChar: 2,
|
||||
};
|
||||
assert.equal(element._getRangeString(side, range),
|
||||
'range-1-1-1-2-PARENT');
|
||||
assert.equal(element._getRangeString(side, null),
|
||||
'line-PARENT');
|
||||
}),
|
||||
|
||||
test('thread groups', () => {
|
||||
const contentEl = document.createElement('div');
|
||||
const commentSide = 'left';
|
||||
|
||||
Reference in New Issue
Block a user