7

I have implemented an Ace editor setup for PHP (which is working fine), but when I try to set additional options using Ace's API, I receive warnings in the console.

Here is the code used to init the editor and try to set the options;

ace.require("ace/ext/language_tools");
ace.require("ace/ext/emmet");

// PHP
var phpeditor = ace.edit("php_inc");
phpeditor.setTheme("ace/theme/dreamweaver");
phpeditor.getSession().setMode("ace/mode/php");
phpeditor.setOptions({
        enableSnippets: true,
        enableLiveAutoComplete: true,
        enableBasicAutocompletion: true,
        showPrintMargin: settings.showPrintMargin,
        useSoftTabs: false,
        fontSize: settings.fontSize,
        showInvisibles: settings.showInvisibles,
        behavioursEnabled: settings.behavioursEnabled,
        tabSize: settings.tabSize,
        useWrapMode: settings.useWrapMode,
        useWorker: settings.useWorker,
        setHighlightActiveLine: false,
        enableEmmet: true
    });

And here are the console warnings I get;

misspelled option "enableSnippets" ace.js?ver=3.9.1:5207
misspelled option "enableLiveAutoComplete" ace.js?ver=3.9.1:5207
misspelled option "enableBasicAutocompletion" ace.js?ver=3.9.1:5207
misspelled option "setHighlightActiveLine" ace.js?ver=3.9.1:5207
misspelled option "enableEmmet" ace.js?ver=3.9.1:5207

Any help will be greatly appreciated.

Harri Bell-Thomas
  • 674
  • 1
  • 7
  • 18
  • 1
    Try setting the options to the session? – EaterOfCode Jul 09 '14 at 10:36
  • 1
    I tried that ( ie. phpeditor.getSession().setOptions({ ... }); ) and still got the same warning messages. Thanks for the idea though! – Harri Bell-Thomas Jul 09 '14 at 11:08
  • 1
    All of the session options can be set from editor, besides none of the misspelled options are session options https://github.com/ajaxorg/ace/blob/v1.1.4/lib/ace/edit_session.js#L2451 – a user Jul 09 '14 at 11:11

1 Answers1

19
  1. you need to include script files for extensions you use see https://github.com/ajaxorg/ace-builds/blob/v1.1.4/demo/autocompletion.html#L28
  2. option name is "enableLiveAutocompletion" instead of "enableLiveAutoComplete" https://github.com/ajaxorg/ace/blob/v1.1.4/lib/ace/ext/language_tools.js#L186
  3. options names do not have set in them so it should be highlightActiveLine

you can see list of all available options by running Object.keys(editor.$options)

a user
  • 23,300
  • 6
  • 58
  • 90
  • Thank you for this - I thought 1 would have been covered by the ace.require(...) statements, but obviously not. 2 was actually something I tried as 'enableLiveAutocompletion' kept coming up as mispelled ( I am still getting 'misspelled option "enableLiveAutocompletion"' - any ideas?) – Harri Bell-Thomas Jul 09 '14 at 11:22
  • maybe you are using old ace version, try to update to latest version. – a user Jul 09 '14 at 12:22
  • I've updated the ace.js file to the latest build - do I need to update all of the files? (I'd rather not, as they have customisations in them) – Harri Bell-Thomas Jul 09 '14 at 13:10
  • enableLiveAutocompletion is defined in ext-language_tools file. I don't think updating only some of the files is a good idea, since there can be some incompatibilities, and also you will miss new bugfixes from ace. What kind of modifications you have? I would either make pull requests to ace core, or create a fork on github and use git merge/rebase to keep my changes synchronised. – a user Jul 09 '14 at 13:24
  • And... it seems that `ace.require("ace/ext/language_tools");` is no need? Tested in v 1.13.1 without this but working. I don't know if it is still needed because there is no document about how to use these extensions. – vee Nov 17 '22 at 09:23