Skip to content

CompletionItem documentation MarkdownString support command arguments #1704

@zhengjiaqi

Description

@zhengjiaqi

monaco-editor version: 0.18.1

[Run it](command:myCommandId)

Does it support args? like use the query-part of the uri in VScode?

I tried

     monaco.languages.registerCompletionItemProvider('javascript', {
         triggerCharacters: ['.'],
         provideCompletionItems(model, position) {
             const params = encodeURIComponent(JSON.stringify({ a: true }));
             return {
                 suggestions: [{
                       insertText: 'text',
                       documentation: {
                            isTrusted: true,
                            value: `[Run it](command:vs.editor.ICodeEditor:1:doc?${params})`
                       },
                 }]
            };
        }
    });

and

monaco.languages.registerCompletionItemProvider('javascript', {
         triggerCharacters: ['.'],
         provideCompletionItems(model, position) {
             const args = [{ a: 1 }];
             const stageCommandUri = monaco.Uri.parse(
                 `command:vs.editor.ICodeEditor:1:doc?${encodeURIComponent(JSON.stringify(args))}`
            );
             return {
                 suggestions: [{
                       insertText: 'text',
                       documentation: {
                            isTrusted: true,
                            value: `[Run it](${stageCommandUri})`
                       },
                 }]
            };
        }
    });

then I addAction, but I can't get the parameters

editor.addAction({
     id: 'doc',
     label: 'doc',
     run: function (params, params2, params3) {
        console.log('###params:', params, params2, params3);
        // print `editor, undefined, undefined`
     }
});

But in VScode we can get the parameters with query-part .
https://code.visualstudio.com/api/extension-guides/command

屏幕快照 2019-12-14 下午2 20 21

屏幕快照 2019-12-14 下午2 20 27

How could I get the parameters with command ? Please help me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedIssues identified as good community contribution opportunitiessuggest

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions