kedro-org / vscode-kedro

Kedro extension for VSCode including LSP and other features
https://marketplace.visualstudio.com/items?itemName=kedro.Kedro
Apache License 2.0
11 stars 2 forks source link

Add new command to change configuration environment #31

Closed noklam closed 2 days ago

noklam commented 1 week ago

Context

Implement a VSCode command to change configuration

select-environment

For reviewer: I'd appreciate feedback specifically on the TS logic since I am relatively new to TS.

datajoely commented 1 week ago

amazing!

datajoely commented 1 week ago

I think my wish of having a status bar you can select is pretty straight forward to do given you have everything you need here:

https://github.com/microsoft/vscode-extension-samples/tree/main/statusbar-sample

and here is a short ChatGPT example:

import * as vscode from 'vscode';

export function activate(context: vscode.ExtensionContext) {
    // Create a status bar item
    const statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 100);
    statusBarItem.text = 'Select Option';
    statusBarItem.command = 'extension.showComboBox';
    statusBarItem.show();
    context.subscriptions.push(statusBarItem);

    // Register the command
    const disposable = vscode.commands.registerCommand('extension.showComboBox', async () => {
        const options = ['Option 1', 'Option 2', 'Option 3'];
        const selectedOption = await vscode.window.showQuickPick(options, {
            placeHolder: 'Select an option',
        });
        if (selectedOption) {
            vscode.window.showInformationMessage(`You selected: ${selectedOption}`);
            statusBarItem.text = selectedOption;
        }
    });
    context.subscriptions.push(disposable);
}

export function deactivate() {}
jitu5 commented 1 week ago

@noklam In terms of code, all good, but I tested it locally with debugger and on selecting command I am getting two options base and local, by selecting local I am getting error Error: Pending response rejected since connection got disposed and server stoped in restartServer function at await newLSClient.start();. same with base.

noklam commented 1 week ago

@jitu5 I see, I test it in this way:

1. make build
2. Install the .vsix (right click on it in VSCode)
3. Open a spaceflights project to test

Debug mode doesn't work because every time a configuration change, the server is restarted (maybe there is a lighter way to do this?). You will experience the same if you do kedro: restart server. For now I reuse the TS function startServer. Maybe there is a way to register command on the server side, which may be better.

noklam commented 1 week ago

@jitu5 Have you tried to use the build? does it work?

jitu5 commented 1 week ago

@jitu5 Have you tried to use the build? does it work?

@noklam Not yet I will try this today with below steps.

  1. make build
  2. Install the .vsix (right click on it in VSCode)
  3. Open a spaceflights project to test
jitu5 commented 1 week ago

@jitu5 Have you tried to use the build? does it work?

@noklam I followed your steps and now its working without debugger also select environment from command. 👍🏼

noklam commented 2 days ago

Thank you, I merge this now!