Search code examples
visual-studio-codevscode-extensions

How to find out which extension provided the command in vscode?


I'm clueless what feature came out of which extension, is there a way to have its source displayed?

Also would be interesteed to know if its possible to trace the source code of the features.


Solution

  • The only thing I can think of is checking the package.json files, as even vscode.commands.getCommands() only returns plain strings. This can be done with the vscode.extensions API:

    import * as vscode from 'vscode';
    
    export function activate(context: vscode.ExtensionContext) {
        setTimeout(() => {
            for (const extension of vscode.extensions.all) {
                let commands = extension.packageJSON.contributes?.commands;
                if (!Array.isArray(commands)) {
                    continue;
                }
                for (const command of commands) {
                    console.log(command.title + " is from " + extension.id);
                }
            }
        }, 2000);
    }
    

    Note that all only includes activated extensions, hence the timeout to make sure all extensions that activate on startup are done with their activation.