Set display line on inline diffs
The gr-diff-view has a set of rules that determine whether the horizontal line under the target row is visible. Extend these rules to the gr-file-list for inline diffs. Bug: Issue 6308 Change-Id: I23a8a0612f045e87e4940bb06988cf215cdd6990
This commit is contained in:
@@ -323,6 +323,7 @@ limitations under the License.
|
|||||||
if="[[_isFileExpanded(file.__path, _expandedFilePaths.*)]]">
|
if="[[_isFileExpanded(file.__path, _expandedFilePaths.*)]]">
|
||||||
<gr-diff
|
<gr-diff
|
||||||
no-auto-render
|
no-auto-render
|
||||||
|
display-line="[[_displayLine]]"
|
||||||
inline-index=[[index]]
|
inline-index=[[index]]
|
||||||
hidden="[[!_isFileExpanded(file.__path, _expandedFilePaths.*)]]"
|
hidden="[[!_isFileExpanded(file.__path, _expandedFilePaths.*)]]"
|
||||||
change-num="[[changeNum]]"
|
change-num="[[changeNum]]"
|
||||||
|
|||||||
@@ -110,6 +110,7 @@
|
|||||||
type: Array,
|
type: Array,
|
||||||
value() { return []; },
|
value() { return []; },
|
||||||
},
|
},
|
||||||
|
_displayLine: Boolean,
|
||||||
},
|
},
|
||||||
|
|
||||||
behaviors: [
|
behaviors: [
|
||||||
@@ -138,6 +139,7 @@
|
|||||||
'n': '_handleNKey',
|
'n': '_handleNKey',
|
||||||
'p': '_handlePKey',
|
'p': '_handlePKey',
|
||||||
'shift+a': '_handleCapitalAKey',
|
'shift+a': '_handleCapitalAKey',
|
||||||
|
'esc': '_handleEscKey',
|
||||||
},
|
},
|
||||||
|
|
||||||
reload() {
|
reload() {
|
||||||
@@ -482,6 +484,7 @@
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (this._showInlineDiffs) {
|
if (this._showInlineDiffs) {
|
||||||
this.$.diffCursor.moveDown();
|
this.$.diffCursor.moveDown();
|
||||||
|
this._displayLine = true;
|
||||||
} else {
|
} else {
|
||||||
this.$.fileCursor.next();
|
this.$.fileCursor.next();
|
||||||
this.selectedIndex = this.$.fileCursor.index;
|
this.selectedIndex = this.$.fileCursor.index;
|
||||||
@@ -496,6 +499,7 @@
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (this._showInlineDiffs) {
|
if (this._showInlineDiffs) {
|
||||||
this.$.diffCursor.moveUp();
|
this.$.diffCursor.moveUp();
|
||||||
|
this._displayLine = true;
|
||||||
} else {
|
} else {
|
||||||
this.$.fileCursor.previous();
|
this.$.fileCursor.previous();
|
||||||
this.selectedIndex = this.$.fileCursor.index;
|
this.selectedIndex = this.$.fileCursor.index;
|
||||||
@@ -895,5 +899,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_handleEscKey(e) {
|
||||||
|
if (this.shouldSuppressKeyboardShortcut(e) ||
|
||||||
|
this.modifierPressed(e)) { return; }
|
||||||
|
e.preventDefault();
|
||||||
|
this._displayLine = false;
|
||||||
|
},
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -1222,5 +1222,24 @@ limitations under the License.
|
|||||||
element._openSelectedFile();
|
element._openSelectedFile();
|
||||||
assert.isTrue(showStub.called);
|
assert.isTrue(showStub.called);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('_displayLine', () => {
|
||||||
|
sandbox.stub(element, 'shouldSuppressKeyboardShortcut', () => false);
|
||||||
|
sandbox.stub(element, 'modifierPressed', () => false);
|
||||||
|
element._showInlineDiffs = true;
|
||||||
|
const mockEvent = {preventDefault() {}};
|
||||||
|
|
||||||
|
element._displayLine = false;
|
||||||
|
element._handleDownKey(mockEvent);
|
||||||
|
assert.isTrue(element._displayLine);
|
||||||
|
|
||||||
|
element._displayLine = false;
|
||||||
|
element._handleUpKey(mockEvent);
|
||||||
|
assert.isTrue(element._displayLine);
|
||||||
|
|
||||||
|
element._displayLine = true;
|
||||||
|
element._handleEscKey(mockEvent);
|
||||||
|
assert.isFalse(element._displayLine);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user