Index: third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js b/third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js |
index 7872902a8c3287ff3140427ab810e47d36659a70..5b5af0f122ddae48b0fbfc11aa421b962cc153fb 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js |
+++ b/third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js |
@@ -68,6 +68,8 @@ Workspace.UISourceCode = class extends Common.Object { |
this._messages = []; |
this._contentLoaded = false; |
+ /** @type {?Promise<?string>} */ |
+ this._originalContentPromise = null; |
/** @type {?string} */ |
this._content = null; |
this._forceLoadOnCheckContent = false; |
@@ -289,10 +291,12 @@ Workspace.UISourceCode = class extends Common.Object { |
* @return {!Promise<?string>} |
*/ |
requestOriginalContent() { |
- var callback; |
- var promise = new Promise(fulfill => callback = fulfill); |
- this._project.requestFileContent(this, callback); |
- return promise; |
+ if (this._originalContentPromise) |
+ return this._originalContentPromise; |
+ var fulfill; |
+ this._originalContentPromise = new Promise(x => fulfill = x); |
+ this._project.requestFileContent(this, fulfill); |
+ return this._originalContentPromise; |
} |
/** |
@@ -300,7 +304,8 @@ Workspace.UISourceCode = class extends Common.Object { |
*/ |
_commitContent(content) { |
if (this._project.canSetFileContent()) { |
- this._project.setFileContent(this, content, function() {}); |
+ // Cache the original content before we overwrite it. |
+ this.requestOriginalContent().then(() => this._project.setFileContent(this, content, function() {})); |
lushnikov
2016/12/20 01:05:23
this should be in filesystemworkspacebindings
|
} else if (this._url && Workspace.fileManager.isURLSaved(this._url)) { |
Workspace.fileManager.save(this._url, content, false, function() {}); |
Workspace.fileManager.close(this._url); |