Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provider APIs and addCommand don't work well together #608

Open
jkillian opened this issue Oct 19, 2017 · 0 comments
Open

Provider APIs and addCommand don't work well together #608

jkillian opened this issue Oct 19, 2017 · 0 comments
Assignees
Milestone

Comments

@jkillian
Copy link

jkillian commented Oct 19, 2017

monaco-editor version: 0.10.1

Providers are registered globally on monaco.languages. However, editor.addCommand returns a commandId that is unique and only applies to one editor. This means if you have multiple editors, they'll all be affected by a provider, but this provider can't work adequately. For example:

const commandHandler = () => { /* whatever */ };
const commandId0 = editor0.addCommand(0, commandHandler, "");
const commandId1 = editor1.addCommand(0, commandHandler, "");

export const codeLensProvider: monaco.languages.CodeLensProvider = {
    provideCodeLenses: (model, cancelToken) => ([
        {
            range: someRange,
            command: {
                id: "???" // which commandId should we use?
                title: "A Command",
                arguments: [],
            }
        }
    ])
};    
monaco.languages.registerCodeLensProvider("*", codeLensProvider);

The easiest solution here is likely to allow addCommand to take an optional id?: string which could be used as the id.

@alexdima alexdima added the debt label Nov 14, 2017
@alexdima alexdima added this to the On Deck milestone Nov 14, 2017
@alexdima alexdima self-assigned this Nov 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants