Enable auto magic complete only when typing

We only want to auto magically complete when the user is typing text,
not when text is pasted or being removed.
This commit is contained in:
Aaron O'Mullan 2014-01-28 01:43:12 +01:00
commit af1aab40f5

View file

@ -121,24 +121,22 @@ var onChangeAutocomplete = function(e, editor) {
var line = session.getLine(pos.row); var line = session.getLine(pos.row);
// Detect paste (poor man's paste detection) // Detect paste (poor man's paste detection)
var pasting = ( var typing = !(
( (
e.data.action === 'insertText' && e.data.action === 'insertText' &&
e.data.text.length > 1 e.data.text.length > 1
) || ) ||
e.data.action === 'insertLines' e.data.action !== 'insertText'
); );
// we don't want to autocomplete on paste events // we don't want to autocomplete on paste events
if(pasting) { if(!typing) {
return; return;
} }
// Append added text to the line // Append added text to the line
if(e.data.action === 'insertText') { line += e.data.text;
line += e.data.text; pos.column += e.data.text.length;
pos.column += e.data.text.length;
}
// The prefix to autocomplete for // The prefix to autocomplete for
var prefix = util.retrievePrecedingIdentifier(line, pos.column); var prefix = util.retrievePrecedingIdentifier(line, pos.column);