the toUpperCase function works but the toggleCommentLines does not work

14 views
Skip to first unread message

kegilko saeba

unread,
Jan 19, 2021, 7:01:46 AM1/19/21
to Ajax.org Cloud9 Editor (Ace)

I am from Symfony 5 and webpack encore, I use ace-builds with the version 1.4.12

Given a webpage with an ace editor bloc (containing some code lines). On pageLoad, I want to automatically upperCase and comment the lines 1 to 2.

I instantiate the ace editor simply like this :

```
let editor = ace.edit(editorElement); // editorElement is an html element containing some code lines
editor.setOptions({
    maxLines: Infinity,
});
editor.getSession().setMode("ace/mode/python");
```

And this is the code executed after the pageLoad :

```
require('ace-builds');
require('ace-builds/webpack-resolver'); // my project is managed by symfony 5 and webpack encore

let Range = require('ace-builds').Range;
editor.getSelection().setRange(new Range(0,0,2,0));

editor.toggleCommentLines(); // does nothing...why ?
editor.toUpperCase(); // its work !
// editor.clearSelection();
```

The result is :

Screenshot from 2021-01-19 12-29-50.png

The lines 1 and 2 are in upperCase as expected, but the lines aren't commented and I don't understand why...

I don't won't "just" add a '#' char because the mode of the generated ace editor may change. By example, the mode may be 'ace/mode/sql', and the comment in sql don't use the '#' char

Thanks for any help :)

Reply all
Reply to author
Forward
0 new messages