Close auto magic complete when prefix is empty
While removing text
This commit is contained in:
parent
c4012ebd46
commit
98dc63cce4
1 changed files with 10 additions and 2 deletions
|
|
@ -119,6 +119,7 @@ var onChangeAutocomplete = function(e, editor) {
|
||||||
var session = editor.getSession();
|
var session = editor.getSession();
|
||||||
var pos = editor.getCursorPosition();
|
var pos = editor.getCursorPosition();
|
||||||
var line = session.getLine(pos.row);
|
var line = session.getLine(pos.row);
|
||||||
|
var hasCompleter = (editor.completer && editor.completer.activated);
|
||||||
|
|
||||||
// Detect paste (poor man's paste detection)
|
// Detect paste (poor man's paste detection)
|
||||||
var typing = !(
|
var typing = !(
|
||||||
|
|
@ -129,6 +130,15 @@ var onChangeAutocomplete = function(e, editor) {
|
||||||
e.data.action !== 'insertText'
|
e.data.action !== 'insertText'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// We don't want to autocomplete with no prefix
|
||||||
|
if(
|
||||||
|
e.data.action === 'removeText' &&
|
||||||
|
util.retrievePrecedingIdentifier(line, pos.column) === ''
|
||||||
|
) {
|
||||||
|
if(hasCompleter) editor.completer.detach();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// we don't want to autocomplete on paste events
|
// we don't want to autocomplete on paste events
|
||||||
if(!typing) {
|
if(!typing) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -141,8 +151,6 @@ var onChangeAutocomplete = function(e, editor) {
|
||||||
// The prefix to autocomplete for
|
// The prefix to autocomplete for
|
||||||
var prefix = util.retrievePrecedingIdentifier(line, pos.column);
|
var prefix = util.retrievePrecedingIdentifier(line, pos.column);
|
||||||
|
|
||||||
var hasCompleter = (editor.completer && editor.completer.activated);
|
|
||||||
|
|
||||||
// Only autocomplete if there's a prefix that can be matched
|
// Only autocomplete if there's a prefix that can be matched
|
||||||
if(prefix !== '' && !(hasCompleter)) {
|
if(prefix !== '' && !(hasCompleter)) {
|
||||||
if (!editor.completer) {
|
if (!editor.completer) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue