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

Should autocomplete popup close on space? #2467

Closed
trystanclarke opened this issue Apr 23, 2015 · 4 comments
Closed

Should autocomplete popup close on space? #2467

trystanclarke opened this issue Apr 23, 2015 · 4 comments

Comments

@trystanclarke
Copy link
Contributor

In the way I use the autocomplete it is better that the popup closes on enter of space character.

For example, typing sql syntax (with live autocomplete on) when I type a whole identifier e.g. 'and' and then a space, the popup stays open and continues trying to match including the 'and' when I have already finished the word. In a desktop editor e.g. visual studio the autocomplete closes at this point.

I have a local fix for this in my completer where I add an additional command binding to the Autocomplete, but thought this might be a behaviour you wish to include by default. This can be achieved with a new command binding to 'Space' in the autocomplete object:

        "Space": function (editor) {
            editor.completer.detach();
            editor.execCommand("insertstring", " ");
        },

here:
https://github.com/ajaxorg/ace/blob/master/lib/ace/autocomplete.js#L207

This may not be appropriate in other cases but thought it was worth a mention.

@nightwing
Copy link
Member

Normally autocomplete closes when there are no matching completions, so space should be handled automatically. But for your example from #2463 it might not work since you are adding space for formatting. Is this a problem only for space or for other characters ([ ( ) as well

@trystanclarke
Copy link
Contributor Author

Hmm, yes you are right, it is due to having spaces in some of the completions I think. Well, the space command mapping fixes this for me.
Yes, it also happens when closing off an identifier with ], the popup remains open as it matches the ] in other suggestions. Could I add a command mapping for this too? Otherwise I may keep the chars () [] out of the display text altogether.

@nightwing
Copy link
Member

One possible solution would be to add a check at https://github.com/ajaxorg/ace/blob/master/lib/ace/autocomplete.js#L278 to close popup if last character is one of ending characters specified by autocompleter, however i am not sure how convenient this would be to use.

@github-actions
Copy link

github-actions bot commented May 9, 2022

This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

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

2 participants