diff --git a/vscode/microsoft-kiota/src/commands/deleteWorkspaceItem/deleteWorkspaceItemCommand.ts b/vscode/microsoft-kiota/src/commands/deleteWorkspaceItem/deleteWorkspaceItemCommand.ts index bc6dd91a41..8d84b15a3e 100644 --- a/vscode/microsoft-kiota/src/commands/deleteWorkspaceItem/deleteWorkspaceItemCommand.ts +++ b/vscode/microsoft-kiota/src/commands/deleteWorkspaceItem/deleteWorkspaceItemCommand.ts @@ -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); } diff --git a/vscode/microsoft-kiota/src/providers/workspaceTreeProvider.ts b/vscode/microsoft-kiota/src/providers/workspaceTreeProvider.ts index 70c9540f13..a7ed3f9943 100644 --- a/vscode/microsoft-kiota/src/providers/workspaceTreeProvider.ts +++ b/vscode/microsoft-kiota/src/providers/workspaceTreeProvider.ts @@ -78,7 +78,7 @@ export class WorkspaceTreeProvider implements vscode.TreeDataProvider - new WorkspaceTreeItem(pluginName, vscode.TreeItemCollapsibleState.None, 'item', PLUGINS, this.getProperties(pluginName, CLIENTS)) + new WorkspaceTreeItem(pluginName, vscode.TreeItemCollapsibleState.None, 'item', PLUGINS, this.getProperties(pluginName, PLUGINS)) ); } } @@ -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'); + } + }) + ); }; \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/test/suite/commands/deleteWorkspaceItemCommand.test.ts b/vscode/microsoft-kiota/src/test/suite/commands/deleteWorkspaceItemCommand.test.ts index cc721a2566..b431e29e36 100644 --- a/vscode/microsoft-kiota/src/test/suite/commands/deleteWorkspaceItemCommand.test.ts +++ b/vscode/microsoft-kiota/src/test/suite/commands/deleteWorkspaceItemCommand.test.ts @@ -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); }); + }); \ No newline at end of file