From 50ef982e1ecd566e6ac7a2ede7d7dc8eaff399c8 Mon Sep 17 00:00:00 2001 From: liximomo Date: Sun, 18 Mar 2018 14:38:27 +0800 Subject: [PATCH] fix #136 --- src/commands/Command.ts | 7 +++++++ src/commands/FileCommand.ts | 13 +------------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/commands/Command.ts b/src/commands/Command.ts index 022923e4..8461da35 100644 --- a/src/commands/Command.ts +++ b/src/commands/Command.ts @@ -1,6 +1,7 @@ import * as vscode from 'vscode'; import * as output from '../modules/output'; import logger from '../logger'; +import { getWorkspaceFolders } from '../host'; export interface ITarget { fsPath: string; @@ -46,6 +47,12 @@ export default class Command { } async run(...args) { + const workspaceFolders = getWorkspaceFolders(); + if (!workspaceFolders) { + vscode.window.showErrorMessage('The SFTP extension requires to work with an opened folder.'); + return; + } + logger.debug(`run command ${this.getName()}`, ...args); try { await this.handler(...args); diff --git a/src/commands/FileCommand.ts b/src/commands/FileCommand.ts index 01d8660a..6df8af2c 100644 --- a/src/commands/FileCommand.ts +++ b/src/commands/FileCommand.ts @@ -2,7 +2,6 @@ import * as vscode from 'vscode'; import Command from './Command'; import * as output from '../modules/output'; import { getConfig } from '../modules/config'; -import { getWorkspaceFolders } from '../host'; import logger from '../logger'; export interface FileTarget { @@ -43,19 +42,9 @@ export default class FileCommand extends Command { decorateHandler(handler) { return async (item, items) => { - const workspaceFolders = getWorkspaceFolders(); - if (!workspaceFolders) { - vscode.window.showErrorMessage( - 'The SFTP extension requires to work with an opened folder.' - ); - return; - } - const targets = await this.getFileTarget(item, items); if (!targets) { - vscode.window.showWarningMessage( - `The "${this.getName()}" command can not find a target.` - ); + vscode.window.showWarningMessage(`The "${this.getName()}" command can not find a target.`); return; }