Index: third_party/WebKit/Source/devtools/front_end/workspace_diff/WorkspaceDiff.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/workspace_diff/WorkspaceDiff.js b/third_party/WebKit/Source/devtools/front_end/workspace_diff/WorkspaceDiff.js |
index dcda6053a0a53d24ccfcc00723d5285b0aec96bf..09503face3cff0c06e3f9c036b3399f0161b2cdf 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/workspace_diff/WorkspaceDiff.js |
+++ b/third_party/WebKit/Source/devtools/front_end/workspace_diff/WorkspaceDiff.js |
@@ -89,8 +89,7 @@ WorkspaceDiff.WorkspaceDiff = class extends Common.Object { |
*/ |
_uiSourceCodeRemoved(event) { |
var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (event.data); |
- this._loadingUISourceCodes.delete(uiSourceCode); |
- this._markAsUnmodified(uiSourceCode); |
+ this._removeUISourceCode(uiSourceCode); |
} |
/** |
@@ -98,10 +97,16 @@ WorkspaceDiff.WorkspaceDiff = class extends Common.Object { |
*/ |
_projectRemoved(event) { |
var project = /** @type {!Workspace.Project} */ (event.data); |
- for (var uiSourceCode of project.uiSourceCodes()) { |
- this._loadingUISourceCodes.delete(uiSourceCode); |
- this._markAsUnmodified(uiSourceCode); |
- } |
+ for (var uiSourceCode of project.uiSourceCodes()) |
+ this._removeUISourceCode(uiSourceCode); |
+ } |
+ |
+ _removeUISourceCode(uiSourceCode) { |
lushnikov
2017/06/08 00:06:51
let's jsdoc this
einbinder
2017/06/08 01:27:55
Done.
|
+ this._loadingUISourceCodes.delete(uiSourceCode); |
+ var uiSourceCodeDiff = this._uiSourceCodeDiffs.get(uiSourceCode); |
+ if (uiSourceCodeDiff) |
+ uiSourceCodeDiff._invalidated = true; |
+ this._markAsUnmodified(uiSourceCode); |
} |
/** |
@@ -171,6 +176,7 @@ WorkspaceDiff.WorkspaceDiff.UISourceCodeDiff = class extends Common.Object { |
uiSourceCode.addEventListener(Workspace.UISourceCode.Events.WorkingCopyCommitted, this._uiSourceCodeChanged, this); |
this._requestDiffPromise = null; |
this._pendingChanges = null; |
+ this._invalidated = false; |
lushnikov
2017/06/08 00:06:51
how about this._disposed? Feels like a better name
einbinder
2017/06/08 01:27:55
Done.
|
} |
_uiSourceCodeChanged() { |
@@ -188,6 +194,8 @@ WorkspaceDiff.WorkspaceDiff.UISourceCodeDiff = class extends Common.Object { |
* @this {WorkspaceDiff.WorkspaceDiff.UISourceCodeDiff} |
*/ |
function emitDiffChanged() { |
+ if (this._invalidated) |
+ return; |
this.dispatchEventToListeners(WorkspaceDiff.Events.DiffChanged); |
this._pendingChanges = null; |
} |
@@ -206,10 +214,19 @@ WorkspaceDiff.WorkspaceDiff.UISourceCodeDiff = class extends Common.Object { |
* @return {!Promise<?Diff.Diff.DiffArray>} |
*/ |
async _innerRequestDiff() { |
+ if (this._invalidated) |
+ return null; |
+ |
var current = this._uiSourceCode.workingCopy(); |
if (!current && !this._uiSourceCode.contentLoaded()) |
current = await this._uiSourceCode.requestContent(); |
lushnikov
2017/06/08 00:06:51
while we are here: let's add a huge // ------ ASYN
einbinder
2017/06/08 01:27:55
Done.
|
+ if (this._invalidated) |
+ return null; |
+ |
var baseline = await this._uiSourceCode.requestOriginalContent(); |
lushnikov
2017/06/08 00:06:51
and let's add the "ASYNC" comment here as well
einbinder
2017/06/08 01:27:55
Done.
|
+ if (this._invalidated) |
+ return null; |
+ |
if (current === null || baseline === null) |
return null; |
return Diff.Diff.lineDiff(baseline.split('\n'), current.split('\n')); |