Calling c# autocomplete from our asp.net application using codemirror

279 views
Skip to first unread message

rbmanian75

unread,
Jun 23, 2017, 12:35:40 PM6/23/17
to rextester
Hi,

I am using your roslyn autocomplete in my codemirror c# editor like this

    CodeMirror.registerHelper(
                "hint",
                "csharp",
                (cm, callback, options) => {
                    var cur = cm.getCursor();
                    var tok = cm.getTokenAt(cur);

                    $.post(
                        "http://rextester.com/service/codecompletion",
                        {
                            code: cm.getValue(),
                            position: cm.indexFromPos(cur),
                            language: 1,
                            line: cur.line,
                            ch: cur.ch
                        },
                        (result) => {
                            callback({
                                list: JSON.parse(result) || [],
                                from: CodeMirror.Pos(cur.line, tok.end),
                                to: CodeMirror.Pos(cur.line, tok.end)
                            });
                        }
                    );
                });

            CodeMirror.commands.autocomplete = cm => {
                CodeMirror.showHint(cm, CodeMirror.hint.csharp, { async: true });
            };

It seems to be working fine.

But i have an issue. When autocomplete list box is displayed typing more does not filter the list. How to filter the autocomplete list base on what user types.

Thanks

ren

unread,
Jun 23, 2017, 12:44:55 PM6/23/17
to rextester
Hi,

once you have the completions filtering is happening in client side. I don't remember how exactly, I think you can look up in codemirror's demo.

Regards,
ren

ren

unread,
Jun 23, 2017, 1:35:31 PM6/23/17
to rextester
By the way here is the code if you want to build your own codwe completion: http://rextester.com/discussion/BVOBB81640/C-code-completion-using-Roslyn-Beta-
Reply all
Reply to author
Forward
0 new messages