cleanup
This commit is contained in:
parent
c3dd9ff510
commit
4599dc6834
3 changed files with 27 additions and 28 deletions
|
|
@ -180,12 +180,15 @@ var Autocomplete = function() {
|
||||||
|
|
||||||
"Esc": function(editor) { editor.completer.detach(); },
|
"Esc": function(editor) { editor.completer.detach(); },
|
||||||
"Space": function(editor) { editor.completer.detach(); editor.insert(" ");},
|
"Space": function(editor) { editor.completer.detach(); editor.insert(" ");},
|
||||||
"Return": function(editor) {
|
"Return": function(editor) { return editor.completer.insertMatch(); },
|
||||||
if (editor.completer.popup.getRow() == -1)
|
|
||||||
return false;
|
|
||||||
editor.completer.insertMatch();
|
|
||||||
},
|
|
||||||
"Shift-Return": function(editor) { editor.completer.insertMatch(true); },
|
"Shift-Return": function(editor) { editor.completer.insertMatch(true); },
|
||||||
|
"Tab": function(editor) {
|
||||||
|
var result = editor.completer.insertMatch();
|
||||||
|
if (!result && !editor.tabstopManager)
|
||||||
|
editor.completer.goTo("down");
|
||||||
|
else
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
|
||||||
"PageUp": function(editor) { editor.completer.popup.gotoPageUp(); },
|
"PageUp": function(editor) { editor.completer.popup.gotoPageUp(); },
|
||||||
"PageDown": function(editor) { editor.completer.popup.gotoPageDown(); }
|
"PageDown": function(editor) { editor.completer.popup.gotoPageDown(); }
|
||||||
|
|
@ -207,16 +210,16 @@ var Autocomplete = function() {
|
||||||
completer.getCompletions(editor, session, pos, prefix, function(err, results) {
|
completer.getCompletions(editor, session, pos, prefix, function(err, results) {
|
||||||
if (!err)
|
if (!err)
|
||||||
matches = matches.concat(results);
|
matches = matches.concat(results);
|
||||||
// Fetch prefix again, because they may have changed by now
|
// Fetch prefix again, because they may have changed by now
|
||||||
var pos = editor.getCursorPosition();
|
var pos = editor.getCursorPosition();
|
||||||
var line = session.getLine(pos.row);
|
var line = session.getLine(pos.row);
|
||||||
callback(null, {
|
callback(null, {
|
||||||
prefix: util.retrievePrecedingIdentifier(line, pos.column, results.length > 0 ? results[0].identifierRegex : undefined),
|
prefix: util.retrievePrecedingIdentifier(line, pos.column, results[0] && results[0].identifierRegex),
|
||||||
matches: matches,
|
matches: matches,
|
||||||
finished: (--total === 0)
|
finished: (--total === 0)
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -268,17 +271,9 @@ var Autocomplete = function() {
|
||||||
return this.detach();
|
return this.detach();
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
// Calcul prefix
|
|
||||||
var prefix = results.prefix;
|
var prefix = results.prefix;
|
||||||
|
|
||||||
// Results matches
|
|
||||||
var matches = results && results.matches;
|
var matches = results && results.matches;
|
||||||
if (!matches || !matches.length)
|
|
||||||
return this.detach();
|
|
||||||
// TODO reenable this when we have proper change tracking
|
|
||||||
// if (matches.length == 1)
|
|
||||||
// return this.insertMatch(matches[0]);
|
|
||||||
|
|
||||||
if (!matches || !matches.length)
|
if (!matches || !matches.length)
|
||||||
return doDetach();
|
return doDetach();
|
||||||
|
|
||||||
|
|
@ -323,6 +318,8 @@ Autocomplete.startCommand = {
|
||||||
exec: function(editor) {
|
exec: function(editor) {
|
||||||
if (!editor.completer)
|
if (!editor.completer)
|
||||||
editor.completer = new Autocomplete();
|
editor.completer = new Autocomplete();
|
||||||
|
editor.completer.autoInsert =
|
||||||
|
editor.completer.autoSelect = true;
|
||||||
editor.completer.showPopup(editor);
|
editor.completer.showPopup(editor);
|
||||||
// needed for firefox on mac
|
// needed for firefox on mac
|
||||||
editor.completer.cancelContextMenu();
|
editor.completer.cancelContextMenu();
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ var expandSnippet = {
|
||||||
if (!success)
|
if (!success)
|
||||||
editor.execCommand("indent");
|
editor.execCommand("indent");
|
||||||
},
|
},
|
||||||
bindKey: "tab"
|
bindKey: "Tab"
|
||||||
};
|
};
|
||||||
|
|
||||||
var onChangeMode = function(e, editor) {
|
var onChangeMode = function(e, editor) {
|
||||||
|
|
@ -122,17 +122,18 @@ var doLiveAutocomplete = function(e) {
|
||||||
var line = editor.session.getLine(pos.row);
|
var line = editor.session.getLine(pos.row);
|
||||||
var hasCompleter = editor.completer && editor.completer.activated;
|
var hasCompleter = editor.completer && editor.completer.activated;
|
||||||
var prefix = util.retrievePrecedingIdentifier(line, pos.column);
|
var prefix = util.retrievePrecedingIdentifier(line, pos.column);
|
||||||
//Try to find custom prefixes on the completors
|
|
||||||
completers.forEach(function(completer){
|
//Try to find custom prefixes on the completers
|
||||||
if(completer.identifierRegexprs){
|
completers.forEach(function(completer) {
|
||||||
completer.identifierRegexprs.forEach(function(identifierRegex){
|
if (completer.identifierRegexps) {
|
||||||
if(!prefix) {
|
completer.identifierRegexps.forEach(function(identifierRegex){
|
||||||
|
if (!prefix) {
|
||||||
prefix = util.retrievePrecedingIdentifier(line, pos.column, identifierRegex);
|
prefix = util.retrievePrecedingIdentifier(line, pos.column, identifierRegex);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// We don't want to autocomplete with no prefix
|
// We don't want to autocomplete with no prefix
|
||||||
if (e.command.name === "backspace" && !prefix) {
|
if (e.command.name === "backspace" && !prefix) {
|
||||||
if (hasCompleter)
|
if (hasCompleter)
|
||||||
|
|
@ -145,6 +146,7 @@ var doLiveAutocomplete = function(e) {
|
||||||
// Create new autocompleter
|
// Create new autocompleter
|
||||||
editor.completer = new Autocomplete();
|
editor.completer = new Autocomplete();
|
||||||
// Disable autoInsert
|
// Disable autoInsert
|
||||||
|
editor.completer.autoSelect = false;
|
||||||
editor.completer.autoInsert = false;
|
editor.completer.autoInsert = false;
|
||||||
}
|
}
|
||||||
editor.completer.showPopup(editor);
|
editor.completer.showPopup(editor);
|
||||||
|
|
|
||||||
|
|
@ -379,7 +379,7 @@ var SnippetManager = function() {
|
||||||
scope = scope.split("/").pop();
|
scope = scope.split("/").pop();
|
||||||
if (scope === "html" || scope === "php") {
|
if (scope === "html" || scope === "php") {
|
||||||
// PHP is actually HTML
|
// PHP is actually HTML
|
||||||
if (scope === "php")
|
if (scope === "php" && !editor.session.$mode.inlinePhp)
|
||||||
scope = "html";
|
scope = "html";
|
||||||
var c = editor.getCursorPosition()
|
var c = editor.getCursorPosition()
|
||||||
var state = editor.session.getState(c.row);
|
var state = editor.session.getState(c.row);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue