Custom autostart and periods (.)

I cannot get getCompletions function to run in my custom add-on when using custom extract pregex identifier identifierRegexps prefix

Basically I am trying to create an autorun that will run in periods (.) Preceded by letters. For instance. In the "foo". when a period is set, I would like to present my own suggestions.

var lang = ace.require("ace/ext/language_tools"); var editor = ace.edit("editor"); editor.getSession().setMode("ace/mode/javascript"); editor.setOptions({ enableBasicAutocompletion: true, enableSnippets: true, enableLiveAutocompletion: true }); var compl = { identifierRegexps: [/[a-zA-Z_0-9\.\$\-\u00A2-\uFFFF]/], getCompletions: function (editor, session, pos, prefix, callback) { alert(prefix); callback(null, []); return; } } lang.addCompleter(compl); 

With the above snippet, a pop-up window appears with suggestions when entering a point, but getCompletions does not start. However, it works for any other character.

UPDATE:

Removing default add-ons before adding custom with

 lang.setCompleters(); 

calls the getCompletion function. However, the prefix argument is empty in this case.

+6
source share
3 answers

I managed to solve this problem by changing the ID_REGEX var in the language_tools.js file.

+2
source

In the ext-language-tools.js file

Replace var ID_REGEX = /[a-zA-Z_0-9\$\-\u00A2-\uFFFF]/;

to

 var ID_REGEX = /[a-zA-Z_0-9\.\$\-\u00A2-\uFFFF]/; 

With the above ID_REGEX, autocomplete will now start in periods (.)

0
source

Changing the language_tools.js file is not a good solution, you can customize the regular expression pattern by calling the getCompletionRegex method:

 editor.getCompletionRegex = () => /[a-zA-Z_0-9.\$\-\u00A2-\uFFFF]/; 
0
source

Source: https://habr.com/ru/post/1214915/


All Articles