Skip to content

Commit

Permalink
Fix: refresh my workspace (#5873)
Browse files Browse the repository at this point in the history
  • Loading branch information
thewahome authored Dec 5, 2024
1 parent 8dae4ca commit 2a39c38
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
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
10 changes: 9 additions & 1 deletion vscode/microsoft-kiota/src/providers/workspaceTreeProvider.ts
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);
});

});

0 comments on commit 2a39c38

Please sign in to comment.