Purge copy/paste cache when diff changes
Bug: Issue 5441 Change-Id: Ifa180dbb4acedce17bc7b75186386d539de5b80e
This commit is contained in:
parent
389bd71cb3
commit
56961e7039
polygerrit-ui/app/elements/diff/gr-diff-selection
@ -24,6 +24,8 @@
|
||||
RIGHT: 'selected-right',
|
||||
};
|
||||
|
||||
var getNewCache = function() { return {left: null, right: null}; };
|
||||
|
||||
Polymer({
|
||||
is: 'gr-diff-selection',
|
||||
|
||||
@ -32,10 +34,14 @@
|
||||
_cachedDiffBuilder: Object,
|
||||
_linesCache: {
|
||||
type: Object,
|
||||
value: function() { return {left: null, right: null}; },
|
||||
value: getNewCache(),
|
||||
},
|
||||
},
|
||||
|
||||
observers: [
|
||||
'_diffChanged(diff)',
|
||||
],
|
||||
|
||||
listeners: {
|
||||
'copy': '_handleCopy',
|
||||
'down': '_handleDown',
|
||||
@ -53,6 +59,10 @@
|
||||
return this._cachedDiffBuilder;
|
||||
},
|
||||
|
||||
_diffChanged: function() {
|
||||
this._linesCache = getNewCache();
|
||||
},
|
||||
|
||||
_handleDown: function(e) {
|
||||
var lineEl = this.diffBuilder.getLineElByChild(e.target);
|
||||
if (!lineEl) {
|
||||
|
@ -325,5 +325,12 @@ limitations under the License.
|
||||
'is is a co');
|
||||
});
|
||||
});
|
||||
|
||||
test('cache is reset when diff changes', function() {
|
||||
element._linesCache = {left: 'test', right: 'test'};
|
||||
element.diff = {};
|
||||
flushAsynchronousOperations();
|
||||
assert.deepEqual(element._linesCache, {left: null, right: null});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user