Skip to content

Issue when with multiple code lens provider for the same model #360

Closed

Description

No description provided.

Activity

  1. added
    bug
    on Nov 20, 2015
  2. added a commit that references this issue on Nov 25, 2015
    770ede1
  3. aeschli commented on Dec 17, 2015

    @aeschli
    Contributor

    Verified with the following example:

    // The module 'vscode' contains the VS Code extensibility API
    // Import the module and reference it with the alias vscode in your code below
    import * as vscode from 'vscode'; 
    
    // this method is called when your extension is activated
    // your extension is activated the very first time the command is executed
    export function activate(context: vscode.ExtensionContext) {
    
        // Use the console to output diagnostic information (console.log) and errors (console.error)
        // This line of code will only be executed once when your extension is activated
        console.log('Congratulations, your extension "my-extension2" is now active!'); 
    
        // The command has been defined in the package.json file
        // Now provide the implementation of the command with  registerCommand
        // The commandId parameter must match the command field in package.json
        var disposable = vscode.commands.registerCommand('extension.sayHello', () => {
            // The code you place here will be executed every time your command is executed
    
            // Display a message box to the user
            vscode.window.showInformationMessage('Hello World!');
        });
    
        var s1 = vscode.languages.registerCodeLensProvider('javascript', {
            provideCodeLenses: (doc, ct) => {
                console.log('provideCodeLenses1'); 
                var codeLenses: vscode.CodeLens[] = [];
                codeLenses.push( {
                    range: doc.lineAt(0).range,
                    command: { title: 'Foo', command: 'extension.sayHello'},
                    isResolved: true
                });
                return codeLenses;
    
            },
            resolveCodeLens: (codeLens: vscode.CodeLens, token: vscode.CancellationToken) => {
                return codeLens;
            }
    
        });
    
        var s2 = vscode.languages.registerCodeLensProvider('javascript', {
            provideCodeLenses: (doc, ct) => {
                console.log('provideCodeLenses2'); 
                var codeLenses: vscode.CodeLens[] = [];
                codeLenses.push( {
                    range: doc.lineAt(0).range,
                    command: { title: 'Bar', command: 'extension.sayHello'},
                    isResolved: true
                });
                return codeLenses;
    
            },
            resolveCodeLens: (codeLens: vscode.CodeLens, token: vscode.CancellationToken) => {
                return codeLens;
            }
    
        });
        context.subscriptions.push(s1);
        context.subscriptions.push(s2);
        context.subscriptions.push(disposable);
    }
  4. locked and limited conversation to collaborators on Nov 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions