Don't crash on empty diff selection

Side-by-side diff doesn't contain .contentText which is used for triple
click handling. Add a null guard to prevent run-time exception.

Bug: Issue 5677
Change-Id: I76d49912af456e156c7cb7b0a31a810ff2b1ac97
This commit is contained in:
Viktar Donich
2017-07-11 13:28:07 -07:00
parent d4bdbb93c2
commit 936630a482

View File

@@ -173,13 +173,14 @@
end.column === 0 &&
end.line === start.line &&
end.side != start.side;
if (endsOnOtherSideStart || endsAtOtherSideLineNum) {
const content = domRange.cloneContents().querySelector('.contentText');
const lineLength = content && this._getLength(content) || 0;
if (lineLength && endsOnOtherSideStart || endsAtOtherSideLineNum) {
// Selection ends at the beginning of the next line.
// Move the selection to the end of the previous line.
range.end = {
node: start.node,
column: this._getLength(
domRange.cloneContents().querySelector('.contentText')),
column: lineLength,
side: start.side,
line: start.line,
};