How to disable "local" auto-completions without affection custom auto-completions?

1,453 views
Skip to first unread message

Chris Ainsley

unread,
Jun 27, 2014, 6:51:22 PM6/27/14
to ace-d...@googlegroups.com
Hi,

I'm testing Ace Editor GWT (which has just today exposed the autocompletion APIs), and the problem is that I just want to use my explicit callback based autocompleters, not the "local" autocompletions.

This is for two reasons:

1) Local autocompletions seem to slow down the editor, which I guess is to do with the constant tokenization of words in the editor.
2) Local completions give the user too many options that don't make sense in all context.

My question is, what is the approved method of disabling local completions (such that the text isn't also tokenized in the background too -- which is greatly slowing down the editor on medium size documents)?

If an existing method of achieving this does not exist, might I suggest adding support for the following flag:

editor.setOptions({ enableLocalAutocompletion: false });

Regards,

Chris

Harutyun Amirjanyan

unread,
Jun 27, 2014, 7:03:07 PM6/27/14
to ace-d...@googlegroups.com
Hi

you can modify editor.completers array to include only completers you like

Regards,
Harutyun

Chris Ainsley

unread,
Jun 27, 2014, 7:26:23 PM6/27/14
to ace-d...@googlegroups.com
Thanks for the reply. And please excuse me here, for I am a Java coder more than a JavaScript coder, but looking at ext-language_tools.js, it seems that the completers array is not exported, so I can't just replace it with an empty array?

Could I just use? :

    var langTools = ace.require("ace/ext/language_tools");
    var editor = ace.edit("editor");
    editor.setOptions({enableBasicAutocompletion: true});
    langTools .completers = []; // will this work without exports.completers=completers in ext-language_tools.js??
    langTools.addCompleter( << my completer >>);


I'm currently I'm using editor.addCompleter (...) via the GWT wrapper, but there is no API that is exposed for removing a specific completer. If we are manually manipulating the array holding the completers then what is the purpose of using the addCompleter() function at all?

I know this is not implemented right now, but is there any reason you would have an objection to the "enableLocalAutocompletion" flag?

I'm not a JavaScript coder, so I am probably wrong about the completers export issue, I just would like to know if the above snippet will work or not.

Regards,

Chris

Chris Ainsley

unread,
Jun 27, 2014, 8:01:57 PM6/27/14
to ace-d...@googlegroups.com
I added this to ext-language_tools.js :

exports.removeCompleters = function() {
    completers = [];
};

Now if I initialize with the following sequence then I only get my custom completer:

    var langTools = ace.require("ace/ext/language_tools");
    var editor = ace.edit("editor");
    editor.setOptions({enableBasicAutocompletion: true});
    langTools.removeCompleters ();
    langTools.addCompleter( << my completer >>);


This is a suitable workaround, but I'd like to know the approved approach.

Harutyun Amirjanyan

unread,
Jun 29, 2014, 9:21:31 AM6/29/14
to ace-d...@googlegroups.com
I don't like adding enableLocalAutocompletion option since that way
we'll have to add option for each autocompleter, and default
completers will work differently from user defined ones.
I'd say the best way to configure completers is to directly modify
editor.completers array

var langTools = ace.require("ace/ext/language_tools");
var editor = ace.edit("editor");
editor.setOptions({enableBasicAutocompletion: true});
editor.completers = [<< my completer >>]

having langTools.defaultCompleters to modify all editors in one place
would be useful too, i guess, but that doesn't work now.
Reply all
Reply to author
Forward
0 new messages