Merge pull request #1865 from ajaxorg/autocomplete-noselect
Add autoSelect option to auto completion
This commit is contained in:
commit
65822b59fe
1 changed files with 23 additions and 16 deletions
|
|
@ -40,6 +40,7 @@ var snippetManager = require("./snippets").snippetManager;
|
||||||
|
|
||||||
var Autocomplete = function() {
|
var Autocomplete = function() {
|
||||||
this.autoInsert = true;
|
this.autoInsert = true;
|
||||||
|
this.autoSelect = true;
|
||||||
this.keyboardHandler = new HashHandler();
|
this.keyboardHandler = new HashHandler();
|
||||||
this.keyboardHandler.bindKeys(this.commands);
|
this.keyboardHandler.bindKeys(this.commands);
|
||||||
|
|
||||||
|
|
@ -69,8 +70,8 @@ var Autocomplete = function() {
|
||||||
this.popup.setData(this.completions.filtered);
|
this.popup.setData(this.completions.filtered);
|
||||||
|
|
||||||
var renderer = editor.renderer;
|
var renderer = editor.renderer;
|
||||||
|
this.popup.setRow(this.autoSelect ? 0 : -1);
|
||||||
if (!keepPopupPosition) {
|
if (!keepPopupPosition) {
|
||||||
this.popup.setRow(0);
|
|
||||||
this.popup.setFontSize(editor.getFontSize());
|
this.popup.setFontSize(editor.getFontSize());
|
||||||
|
|
||||||
var lineHeight = renderer.layerConfig.lineHeight;
|
var lineHeight = renderer.layerConfig.lineHeight;
|
||||||
|
|
@ -171,7 +172,13 @@ 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) { editor.completer.insertMatch(); },
|
"Return": function(editor) {
|
||||||
|
if (editor.completer.popup.getRow() > -1) {
|
||||||
|
editor.completer.insertMatch();
|
||||||
|
} else {
|
||||||
|
editor.insert("\n");
|
||||||
|
}
|
||||||
|
},
|
||||||
"Shift-Return": function(editor) { editor.completer.insertMatch(true); },
|
"Shift-Return": function(editor) { editor.completer.insertMatch(true); },
|
||||||
"Tab": function(editor) { editor.completer.insertMatch(); },
|
"Tab": function(editor) { editor.completer.insertMatch(); },
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue