| Index: third_party/WebKit/Source/devtools/front_end/snippets/ScriptSnippetModel.js
|
| diff --git a/third_party/WebKit/Source/devtools/front_end/snippets/ScriptSnippetModel.js b/third_party/WebKit/Source/devtools/front_end/snippets/ScriptSnippetModel.js
|
| index 0dc66a264cc229478caee2209668dd844227d723..29f937f8b10fcaae9f5c139c831c4cee574dad73 100644
|
| --- a/third_party/WebKit/Source/devtools/front_end/snippets/ScriptSnippetModel.js
|
| +++ b/third_party/WebKit/Source/devtools/front_end/snippets/ScriptSnippetModel.js
|
| @@ -554,6 +554,8 @@ Snippets.SnippetsProject = class extends Bindings.ContentProviderBasedProject {
|
| constructor(workspace, model) {
|
| super(workspace, 'snippets:', Workspace.projectTypes.Snippets, '', false /* isServiceProject */);
|
| this._model = model;
|
| + /** @type {!WeakMap<!Workspace.UISourceCode, !Promise<?string>>} */
|
| + this._originalContent = new WeakMap();
|
| }
|
|
|
| /**
|
| @@ -572,16 +574,30 @@ Snippets.SnippetsProject = class extends Bindings.ContentProviderBasedProject {
|
| canSetFileContent() {
|
| return true;
|
| }
|
| + /**
|
| + * @override
|
| + * @param {!Workspace.UISourceCode} uiSourceCode
|
| + * @return {!Promise<?string>}
|
| + */
|
| + requestOriginalFileContent(uiSourceCode) {
|
| + if (this._originalContent.has(uiSourceCode))
|
| + return this._originalContent.get(uiSourceCode);
|
| + var promise = super.requestOriginalFileContent(uiSourceCode);
|
| + this._originalContent.set(uiSourceCode, promise);
|
| + return promise;
|
| + }
|
|
|
| /**
|
| * @override
|
| * @param {!Workspace.UISourceCode} uiSourceCode
|
| * @param {string} newContent
|
| - * @param {function(?string)} callback
|
| + * @param {function()} callback
|
| */
|
| setFileContent(uiSourceCode, newContent, callback) {
|
| - this._model._setScriptSnippetContent(uiSourceCode.url(), newContent);
|
| - callback('');
|
| + this.requestOriginalFileContent(uiSourceCode).then(() => {
|
| + this._model._setScriptSnippetContent(uiSourceCode.url(), newContent);
|
| + callback();
|
| + });
|
| }
|
|
|
| /**
|
|
|