Bug 1042825 - Project Editor: Prevent undo from undo clearing out the file content. r=jryans
authorBrian Grinstead <bgrinstead@mozilla.com>
Thu, 07 Aug 2014 06:21:00 -0400
changeset 198578 2ead24c96a8e9e278fca79543c91aac03b031800
parent 198577 5c1ba06b972b6a8b903362ad0ebb9b7112665e86
child 198579 5bf0bbcc85fbcba2ccb1ac2471990281c29811bf
push id27277
push userryanvm@gmail.com
push dateFri, 08 Aug 2014 20:25:17 +0000
treeherdermozilla-central@1d6500527f66 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjryans
bugs1042825
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1042825 - Project Editor: Prevent undo from undo clearing out the file content. r=jryans
browser/devtools/projecteditor/lib/editors.js
browser/devtools/projecteditor/test/browser_projecteditor_editing_01.js
--- a/browser/devtools/projecteditor/lib/editors.js
+++ b/browser/devtools/projecteditor/lib/editors.js
@@ -208,16 +208,17 @@ var TextEditor = Class({
     return promise.all([
       resource.load(),
       this.appended
     ]).then(([resourceContents])=> {
       if (!this.editor) {
         return;
       }
       this.editor.setText(resourceContents);
+      this.editor.clearHistory();
       this.editor.setClean();
       this.emit("load");
     }, console.error);
   },
 
   /**
    * Save the resource based on the current state of the editor
    *
--- a/browser/devtools/projecteditor/test/browser_projecteditor_editing_01.js
+++ b/browser/devtools/projecteditor/test/browser_projecteditor_editing_01.js
@@ -33,16 +33,20 @@ function testEditFile(projecteditor, fil
   let viewContainer= projecteditor.projectTree.getViewContainer(resource);
   let originalTreeLabel = viewContainer.label.textContent;
 
   is (resource.path, filePath, "Resource path is set correctly");
   is (editor.editor.getText(), initialData, "Editor is loaded with correct file contents");
 
   info ("Setting text in the editor and doing checks before saving");
 
+  editor.editor.undo();
+  editor.editor.undo();
+  is (editor.editor.getText(), initialData, "Editor is still loaded with correct contents after undo");
+
   editor.editor.setText(newData);
   is (editor.editor.getText(), newData, "Editor has been filled with new data");
   is (viewContainer.label.textContent, "*" + originalTreeLabel, "Label is marked as changed");
 
   info ("Saving the editor and checking to make sure the file gets saved on disk");
 
   editor.save(resource);