Resize autocomplete dropdown panel

336 views
Skip to first unread message

Mohan Ram S

unread,
Jan 20, 2016, 1:36:57 PM1/20/16
to Ajax.org Cloud9 Editor (Ace)
Hi,

I am unable to resize the autocomplete dropdown panel. I have tried the below code and I am getting the error 'Uncaught ReferenceError: Autocomplete is not defined'.

if (!editor.completer) {
editor.completer = new Autocomplete();
}
editor.completer.$init();
var popup = editor.completer.popup; 
popup.container.style.width="1000px"; 
popup.resize();

I am importing   'ace-builds/src-min-noconflict/ext-language_tools.js' into my page.

Thanks,
Mohan Ram S

Harutyun Amirjanyan

unread,
Jan 22, 2016, 4:57:39 PM1/22/16
to ace-d...@googlegroups.com
you need to load Autocomplete first with require("ace/autocomplete").Autocomplete 
(use ace.require in noconflict version)

Solomon Okolie

unread,
Mar 14, 2016, 7:40:19 AM3/14/16
to Ajax.org Cloud9 Editor (Ace)
I tried your suggestion but still getting same error below is my code
 $(function () {

            var editor = ace.edit("editor");
            editor.setTheme("ace/theme/sqlserver");
            editor.session.setMode("ace/mode/csharp");
           
            editor.getSession().setUseWrapMode(true);
            editor.setShowPrintMargin(false);

            editor.commands.on("afterExec", function (e) {
                if (e.command.name == "insertstring" && /^[\w.]$/.test(e.args)) {

                    if (e.args == '.') {
                        editor.execCommand("startAutocomplete");
                    }
                }
            });

            var serviceId = 1;

            $.ajax('/api/Recommendation/Check?serviceId=1').done(function (data) {
            });

            var auto = ace.require("ace/autocomplete").Autocomplete;
            var langTools = ace.require("ace/ext/language_tools");


            editor.setOptions({
                enableBasicAutocompletion: true,
                enableLiveAutoComplete: true,
                enableSnippets: true
            });
            var codeCompleter = {
                getCompletions: function (editor, session, pos, prefix, callback) {

                    var data = { content: editor.getValue(), serviceId: serviceId, row: pos.row, col: pos.column };
                    $.post('http://localhost:45271/api/Recommendation/Recommend', data, function (response) {
                        var completionData = $.map(response, function (item) {
                            return {
                                name: item.name,
                                value: item.name,
                                score: item.score,
                                docHTML: item.comment
                                
                            }



                        });

                        callback(null, completionData);



                    });

                }
            }

            editor.completers = [codeCompleter];

            SetUpDom(editor, serviceId);

            if (!editor.completer) {
                editor.completer = new Autocomplete(); // here says Autocomplete is not defined
            }
            editor.completer.$init();
            var popup = editor.completer.popup;
            popup.on("changeSelection", function () {
                console.log(popup.getData(popup.getRow()));
            });

        });


Harutyun Amirjanyan

unread,
Mar 15, 2016, 10:17:37 AM3/15/16
to ace-d...@googlegroups.com
Autocomplete is not defined because you have wrote

var auto = ace.require("ace/autocomplete").Autocomplete;

it should be  
var Autocomplete = ace.require("ace/autocomplete").Autocomplete;
or the other line should be `editor.completer = new auto();` instead.

abhishek

unread,
Nov 17, 2017, 2:37:44 AM11/17/17
to Ajax.org Cloud9 Editor (Ace)
I am also trying the same but getting below error:

Uncaught TypeError: Cannot read property 'focus' of undefined
    at Autocomplete.$init (VM229 ext-language_tools.js:1322)

Алексей Юрченко

unread,
Mar 16, 2018, 8:15:39 AM3/16/18
to Ajax.org Cloud9 Editor (Ace)
Just editor prop for Autocomplete
editor.completer.editor = editor

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

пятница, 17 ноября 2017 г., 7:37:44 UTC пользователь abhishek написал:
Reply all
Reply to author
Forward
0 new messages