Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enableLiveAutocompletion documentation does the opposite of what it says #4972

Closed
Ghostbird opened this issue Oct 21, 2022 · 3 comments
Closed

Comments

@Ghostbird
Copy link

Ghostbird commented Oct 21, 2022

Describe the issue

We've had problems getting auto completion to work for a while now. Today I finally found the cause.

The documentation states that to enable autocompletion you should pass an array of completers as value for enableLiveAutoCompletion in setOptions.

The exact wording is:

Enable live autocomplete. If the value is an array, it is assumed to be an array of completers and will use them instead of the default completers.

After debugging this for a while today I concluded that this is simply not what Ace does. After looking at the code I saw that indeed, the actual implementation is:

enableLiveAutocompletion: {
    set: function(val) {
        if (val) {
            if (!this.completers)
                this.completers = Array.isArray(val)? val: completers;
            // On each change automatically trigger the autocomplete
            this.commands.on('afterExec', doLiveAutocomplete);
        } else {
            this.commands.removeListener('afterExec', doLiveAutocomplete);
        }
    },
    value: false
},

The documentation should instead state:

Enable live autocomplete. If the value is an array, it is assumed to be an array of completers and will use them unless you already have completers set e.g. from enableBasicAutocompletion.

Note: enableBasicAutocompletion has the same logic, however this is completely undocumented. There the documentation should read:

Enable basic autocomplete. If the value is an array, it is assumed to be an array of completers and will use them unless you already have completers set e.g. from enableLiveAutocompletion.

After all this, I actually don't know how I'm supposed to set the completers, so for now I just grab the underlying array pointer and force the extra completers in there. It seems to work, but feels like unnecessary cruelty to the editor, and probably bypasses several set-up side-effects.

Links

https://ajaxorg.github.io/ace-api-docs/interfaces/Ace.EditorOptions.html#enableLiveAutocompletion

@andrewnester
Copy link
Contributor

Released in Ace 1.12.5

@Ghostbird
Copy link
Author

Thank you.
From the comments on the commits, I it seems direct direct access to Editor.completers is the intended usage. From the way the API was structured, it seemed to me that this was a “dangerous” shortcut. Many other properties have dedicated get/set functions, but completers one doesn't have any other than these setOptions options.

@nightwing
Copy link
Member

The properties that are not meant to be accessed have by outside code start with $ or _

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants