make sure missing emmet can't break tab key

This commit is contained in:
nightwing 2014-11-05 23:17:59 +04:00
commit 9ccf68dbb2

View file

@ -342,29 +342,29 @@ var keymap = {
var editorProxy = new AceEmmetEditor();
exports.commands = new HashHandler();
exports.runEmmetCommand = function(editor) {
editorProxy.setupContext(editor);
if (editorProxy.getSyntax() == "php")
return false;
var actions = emmet.require("actions");
if (this.action == "expand_abbreviation_with_tab") {
if (!editor.selection.isEmpty())
return false;
}
if (this.action == "wrap_with_abbreviation") {
// without setTimeout prompt doesn't work on firefox
return setTimeout(function() {
actions.run("wrap_with_abbreviation", editorProxy);
}, 0);
}
var pos = editor.selection.lead;
var token = editor.session.getTokenAt(pos.row, pos.column);
if (token && /\btag\b/.test(token.type))
return false;
try {
editorProxy.setupContext(editor);
if (editorProxy.getSyntax() == "php")
return false;
var actions = emmet.require("actions");
if (this.action == "expand_abbreviation_with_tab") {
if (!editor.selection.isEmpty())
return false;
}
if (this.action == "wrap_with_abbreviation") {
// without setTimeout prompt doesn't work on firefox
return setTimeout(function() {
actions.run("wrap_with_abbreviation", editorProxy);
}, 0);
}
var pos = editor.selection.lead;
var token = editor.session.getTokenAt(pos.row, pos.column);
if (token && /\btag\b/.test(token.type))
return false;
var result = actions.run(this.action, editorProxy);
} catch(e) {
editor._signal("changeStatus", typeof e == "string" ? e : e.message);
@ -393,7 +393,7 @@ exports.updateCommands = function(editor, enabled) {
};
exports.isSupportedMode = function(modeId) {
return modeId && /css|less|scss|sass|stylus|html|php|twig/.test(modeId);
return modeId && /css|less|scss|sass|stylus|html|php|twig|ejs/.test(modeId);
};
var onChangeMode = function(e, target) {
@ -406,9 +406,8 @@ var onChangeMode = function(e, target) {
if (enabled) {
if (typeof emmetPath == "string") {
require("ace/config").loadModule(emmetPath, function() {
emmetPath = null;
});
emmetPath = null;
}
}
exports.updateCommands(editor, enabled);