Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
Merge pull request #5282 from adobe/nj/issue-5279
Browse files Browse the repository at this point in the history
Don't reparse HTML files on save
  • Loading branch information
gruehle committed Sep 20, 2013
2 parents b57dfc9 + 7b76015 commit dd28c6a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
11 changes: 0 additions & 11 deletions src/LiveDevelopment/Documents/HTMLDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,8 @@ define(function HTMLDocumentModule(require, exports, module) {
this._instrumentationEnabled = false;

this.onCursorActivity = this.onCursorActivity.bind(this);
this.onDocumentSaved = this.onDocumentSaved.bind(this);

$(this.editor).on("cursorActivity", this.onCursorActivity);
$(DocumentManager).on("documentSaved", this.onDocumentSaved);

// Experimental code
if (LiveDevelopment.config.experimental) {
Expand Down Expand Up @@ -130,7 +128,6 @@ define(function HTMLDocumentModule(require, exports, module) {
}

$(this.editor).off("cursorActivity", this.onCursorActivity);
$(DocumentManager).off("documentSaved", this.onDocumentSaved);

// Experimental code
if (LiveDevelopment.config.experimental) {
Expand Down Expand Up @@ -312,14 +309,6 @@ define(function HTMLDocumentModule(require, exports, module) {
this._highlight = codeMirror.markText(from, to, { className: "highlight" });
};

/** Triggered when a document is saved */
HTMLDocument.prototype.onDocumentSaved = function onDocumentSaved(event, doc) {
if (doc === this.doc) {
HTMLInstrumentation.scanDocument(this.doc);
HTMLInstrumentation._markText(this.editor);
}
};

// Export the class
module.exports = HTMLDocument;
});
1 change: 1 addition & 0 deletions src/brackets.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ define(function (require, exports, module) {
UpdateNotification : require("utils/UpdateNotification"),
InstallExtensionDialog : require("extensibility/InstallExtensionDialog"),
RemoteAgent : require("LiveDevelopment/Agents/RemoteAgent"),
HTMLInstrumentation : require("language/HTMLInstrumentation"),
doneLoading : false
};

Expand Down
27 changes: 26 additions & 1 deletion test/spec/LiveDevelopment-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ define(function (require, exports, module) {
// Spy on RemoteAgent
spyOn(testWindow.brackets.test.RemoteAgent, "call").andCallThrough();

// Create syntax errors
// Edit text
doc = DocumentManager.getCurrentDocument();
doc.replaceRange("Live Preview in ", {line: 11, ch: 33});
});
Expand All @@ -819,6 +819,31 @@ define(function (require, exports, module) {
expect(edit.content).toEqual("Live Preview in Brackets is awesome!");
});
});

it("should not reparse page on save (#5279)", function () {
var doc, saveDeferred = new $.Deferred();

_openSimpleHTML();

runs(function () {
// Make an edit.
doc = DocumentManager.getCurrentDocument();
doc.replaceRange("Live Preview in ", {line: 11, ch: 33});

// Save the document and see if "scanDocument" (which reparses the page) is called.
spyOn(testWindow.brackets.test.HTMLInstrumentation, "scanDocument").andCallThrough();
testWindow.$(DocumentManager).one("documentSaved", function (e, savedDoc) {
expect(savedDoc === doc);
saveDeferred.resolve();
});
CommandManager.execute(Commands.FILE_SAVE, { doc: doc });
waitsForDone(saveDeferred.promise(), "file finished saving");
});

runs(function () {
expect(testWindow.brackets.test.HTMLInstrumentation.scanDocument.callCount).toBe(0);
});
});

});

Expand Down

0 comments on commit dd28c6a

Please sign in to comment.