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

Fix: refresh my workspace #5873

Merged
merged 12 commits into from
Dec 5, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export class DeleteWorkspaceItemCommand extends Command {
const isSuccess = result.some(k => k.message.includes('removed successfully'));
if (isSuccess) {
void vscode.window.showInformationMessage(vscode.l10n.t('{0} removed successfully.', workspaceTreeItem.label));
await vscode.commands.executeCommand('kiota.workspace.refresh');
} else {
await exportLogsAndShowErrors(result, this._kiotaOutputChannel);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class WorkspaceTreeProvider implements vscode.TreeDataProvider<WorkspaceT

if (isPluginType(element.label)) {
return Object.keys(this.workspaceContent.plugins).map(pluginName =>
new WorkspaceTreeItem(pluginName, vscode.TreeItemCollapsibleState.None, 'item', PLUGINS, this.getProperties(pluginName, CLIENTS))
new WorkspaceTreeItem(pluginName, vscode.TreeItemCollapsibleState.None, 'item', PLUGINS, this.getProperties(pluginName, PLUGINS))
);
}
}
Expand Down Expand Up @@ -139,4 +139,12 @@ export async function loadTreeView(context: vscode.ExtensionContext, treeDataPro
await vscode.commands.executeCommand('kiota.editPaths', label, properties, category);
})
);
context.subscriptions.push(
vscode.workspace.onDidChangeTextDocument(async (event: vscode.TextDocumentChangeEvent) => {
const document = event.document;
if (document.fileName.endsWith(KIOTA_WORKSPACE_FILE)) {
await vscode.commands.executeCommand('kiota.workspace.refresh');
}
})
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,13 @@ suite('DeleteWorkspaceItemCommand Tests', () => {

const showWarningMessageStub = sinon.stub(vscode.window, 'showWarningMessage').resolves(yesAnswer);
const showInformationMessageStub = sinon.stub(vscode.window, 'showInformationMessage').resolves();
const executeCommandStub = sinon.stub(vscode.commands, 'executeCommand').resolves();
const deleteItemStub = sinon.stub(command as any, 'deleteItem').resolves([{ message: 'removed successfully' }]);

await command.execute(workspaceTreeItem);

assert.strictEqual(showWarningMessageStub.calledOnce, true);
assert.strictEqual(showInformationMessageStub.calledOnce, true);
assert.strictEqual(executeCommandStub.calledWith('kiota.workspace.refresh'), true);
assert.strictEqual(deleteItemStub.calledOnce, true);
});

});
Loading