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

Don't reparse HTML files on save #5282

Merged
merged 1 commit into from
Sep 20, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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