Bug 1046049 - Fix :w for saving in webide. r=jryans

This commit is contained in:
mitchfriedman 2015-08-20 12:55:00 -04:00
parent 5b75ad5195
commit 14abc7ef19
7 changed files with 11 additions and 7 deletions

View File

@ -180,6 +180,9 @@ var TextEditor = Class({
this.editor.on("focus", (...args) => {
this.emit("focus", ...args);
});
this.editor.on("saveRequested", (...args) => {
this.emit("saveRequested", ...args);
})
this.appended = this.editor.appendTo(this.elt);
},

View File

@ -46,7 +46,7 @@ var SavePlugin = Class({
onCommand: function(cmd) {
if (cmd === "cmd-save") {
this.save();
this.onEditorSaveRequested();
} else if (cmd === "cmd-saveas") {
this.saveAs();
}
@ -71,7 +71,7 @@ var SavePlugin = Class({
}).then(null, console.error);
},
save: function() {
onEditorSaveRequested: function() {
let editor = this.host.currentEditor;
let resource = this.host.resourceFor(editor);
if (!resource) {

View File

@ -554,6 +554,7 @@ var ProjectEditor = Class({
this._editorListenAndDispatch(editor, "change", "onEditorChange");
this._editorListenAndDispatch(editor, "cursorActivity", "onEditorCursorActivity");
this._editorListenAndDispatch(editor, "load", "onEditorLoad");
this._editorListenAndDispatch(editor, "saveRequested", "onEditorSaveRequested");
this._editorListenAndDispatch(editor, "save", "onEditorSave");
editor.on("focus", () => {

View File

@ -1734,7 +1734,7 @@ var Scratchpad = {
msg, okstring);
editorElement.addEventListener("paste", this._onPaste);
editorElement.addEventListener("drop", this._onPaste);
this.editor.on("save", () => this.saveFile());
this.editor.on("saveRequested", () => this.saveFile());
this.editor.focus();
this.editor.setCursor({ line: lines.length, ch: lines.pop().length });

View File

@ -285,7 +285,7 @@ Editor.prototype = {
scssSpec.valueKeywords = cssValues;
win.CodeMirror.defineMIME("text/x-scss", scssSpec);
win.CodeMirror.commands.save = () => this.emit("save");
win.CodeMirror.commands.save = () => this.emit("saveRequested");
// Create a CodeMirror instance add support for context menus,
// overwrite the default controller (otherwise items in the top and

View File

@ -128,7 +128,7 @@
sim("clearMark", "abcde", Pos(0, 2), "Ctrl-Space", "Ctrl-F", "Ctrl-F",
"Ctrl-G", "Ctrl-W", txt("abcde"));
testCM("save", function(cm) {
testCM("saveRequested", function(cm) {
var saved = false;
CodeMirror.commands.save = function(cm) { saved = cm.getValue(); };
cm.triggerOnKeyDown(fakeEvent("Ctrl-X"));

View File

@ -386,7 +386,7 @@ StyleSheetEditor.prototype = {
sourceEditor.on("dirty-change", this._onPropertyChange);
return sourceEditor.appendTo(inputElement).then(() => {
sourceEditor.on("save", this.saveToFile);
sourceEditor.on("saveRequested", this.saveToFile);
if (this.styleSheet.update) {
sourceEditor.on("change", this.updateStyleSheet);
@ -715,7 +715,7 @@ StyleSheetEditor.prototype = {
destroy: function() {
if (this._sourceEditor) {
this._sourceEditor.off("dirty-change", this._onPropertyChange);
this._sourceEditor.off("save", this.saveToFile);
this._sourceEditor.off("saveRequested", this.saveToFile);
this._sourceEditor.off("change", this.updateStyleSheet);
if (this.highlighter && this.walker && this._sourceEditor.container) {
this._sourceEditor.container.removeEventListener("mousemove",