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

Adding '.' character to prefix matching for completers Ref- 'ace/autocomplete/util' #1670

Closed
mccainz opened this issue Oct 31, 2013 · 12 comments

Comments

@mccainz
Copy link

mccainz commented Oct 31, 2013

For consideration,

The module, 'ace/autocomplete/util', in file ext-language_Tools.js, defines a regEx that is used to determine prefix matches for defined completers.

var ID_REGEX = /[a-zA-Z_0-9$-]/;
used in , exports.retrievePrecedingIdentifier

As we defined a custom completer to support our object structures (Person.Name.First etc...) this caused a problem in that ID_REGEX will not match on the dot character. This can be overridden in our custom completer but it causes the completers defined in ace/ext/language_tools to pollute our matches with the entire scope of the document.

The modification seems trivial ...
var ID_REGEX = /[a-zA-Z_0-9$-.]/;

@mccainz
Copy link
Author

mccainz commented Nov 4, 2013

Or rather, could the ID_REGEX be made an option for the ace/autocomplete/util mdoule?

@nightwing
Copy link
Member

yes, making it an option is better

@elektronaut1024
Copy link

I am hitting the same issue. I tried to find a neat way to customize the prefix matching but did not find something viable. Is there a solution available?

I assumed that the Tokenizer of the current mode would be used to determine the current prefix...which would allow dynamic prefix-finding rules...neat? or am I missing something? This way I could create my own mode (maybe not as trivial as I am hoping, but it would fit...right?)

@nightwing
Copy link
Member

Experimental support for this was added some time ago

prefix: util.retrievePrecedingIdentifier(line, pos.column, results[0] && results[0].identifierRegex),
but i am not sure if it works well, and still might change.
Using tokenizer would work if tokenizer is written with that in mind, but many modes won't work since they assign text class to everything that isn't highlighted.

@vqminh
Copy link

vqminh commented Oct 1, 2014

This will be helpful, can't believe auto complete works without this.

@antonpodolsky
Copy link

@nightwing it works (using the first item in the results array to pass the regex)

@ghost
Copy link

ghost commented Aug 9, 2015

@AntonPOD Can you describe what you did to make it work? I opened this issue a couple of months ago.

@antonpodolsky
Copy link

@rsmith31415 in my case I didn't need to know the prefix before sending the Ajax request. I just needed to adjust the regex to also match dots, after the keywords were fetched.
Anyway, it doesn't work as expected, getting some weird matches which look absolutely random.

@ghost
Copy link

ghost commented Aug 15, 2015

@AntonPOD Thank you for your response. Maybe @nightwing can share an update on the support for this feature.

@GNSubrahmanyam
Copy link

@nightwing any updates on this?

@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.

@andrewnester
Copy link
Contributor

Now as a solution for this issue custom identifierRegexps can be provided by authors of custom code completers
https://ajaxorg.github.io/ace-api-docs/interfaces/Ace.Completer.html#identifierRegexps

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

7 participants