diff --git a/packages/zowe-explorer/__tests__/__unit__/commands/ZoweCommandProvider.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/commands/ZoweCommandProvider.unit.test.ts index 7dc9bda8bc..412fb436f8 100644 --- a/packages/zowe-explorer/__tests__/__unit__/commands/ZoweCommandProvider.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/commands/ZoweCommandProvider.unit.test.ts @@ -120,6 +120,13 @@ describe("ZoweCommandProvider Unit Tests", () => { expect(createTerminal).not.toHaveBeenCalled(); }); + it("should not create a terminal if the command is empty", async () => { + const createTerminal = jest.fn().mockReturnValue({ show: jest.fn() }); + Object.defineProperty(vscode.window, "createTerminal", { value: createTerminal, configurable: true }); + await ZoweCommandProvider.prototype.issueCommand.call(mockCmdProvider, testProfile, ""); + expect(createTerminal).not.toHaveBeenCalled(); + }); + it("should create an integrated terminal", async () => { const createTerminal = jest.fn().mockReturnValue({ show: jest.fn() }); Object.defineProperty(vscode.window, "createTerminal", { value: createTerminal, configurable: true }); diff --git a/packages/zowe-explorer/src/commands/ZoweCommandProvider.ts b/packages/zowe-explorer/src/commands/ZoweCommandProvider.ts index e43ab75fa8..27178021d0 100644 --- a/packages/zowe-explorer/src/commands/ZoweCommandProvider.ts +++ b/packages/zowe-explorer/src/commands/ZoweCommandProvider.ts @@ -61,6 +61,10 @@ export abstract class ZoweCommandProvider { if (profile == null || command == null) { return; } + if (command.length === 0) { + Gui.showMessage(this.operationCancelled); + return; + } try { const iTerms = SettingsConfig.getDirectValue(Constants.SETTINGS_COMMANDS_INTEGRATED_TERMINALS); if (iTerms) {