From 70d38eec1b69af6b251c7522cb13963e2c0b99da Mon Sep 17 00:00:00 2001 From: Kelvin Schoofs Date: Wed, 16 Dec 2020 20:41:39 +0100 Subject: [PATCH] Add disconnectAll command (closes #144) --- package.json | 22 +++++++++++++++++++--- src/extension.ts | 7 +++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index d8b5ad2..71106bf 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "onCommand:sshfs.new", "onCommand:sshfs.add", "onCommand:sshfs.disconnect", + "onCommand:sshfs.disconnectAll", "onCommand:sshfs.terminal", "onCommand:sshfs.focusTerminal", "onCommand:sshfs.closeTerminal", @@ -96,6 +97,12 @@ "category": "SSH FS", "icon": "$(debug-disconnect)" }, + { + "command": "sshfs.disconnectAll", + "title": "Disconnect all", + "category": "SSH FS", + "icon": "$(debug-disconnect)" + }, { "command": "sshfs.terminal", "title": "Open remote SSH terminal", @@ -166,9 +173,13 @@ "group": "SSH FS@6" }, { - "command": "sshfs.settings", + "command": "sshfs.disconnectAll", "group": "SSH FS@7" }, + { + "command": "sshfs.settings", + "group": "SSH FS@8" + }, { "command": "sshfs.focusTerminal", "when": "false" @@ -191,17 +202,22 @@ { "command": "sshfs.new", "when": "view == 'sshfs-configs'", - "group": "navigation@1" + "group": "navigation@2" }, { "command": "sshfs.add", "when": "view == 'sshfs-connections'", "group": "navigation@2" }, + { + "command": "sshfs.disconnectAll", + "when": "view == 'sshfs-connections'", + "group": "navigation@3" + }, { "command": "sshfs.settings", "when": "view == 'sshfs-configs' || view == 'sshfs-connections'", - "group": "navigation@3" + "group": "navigation@100" } ], "view/item/context": [ diff --git a/src/extension.ts b/src/extension.ts index 7bf62a4..5f0902d 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -83,6 +83,13 @@ export function activate(context: vscode.ExtensionContext) { handleConnection: con => manager.commandDisconnect(con), }); + // sshfs.disconnectAll() + registerCommand('sshfs.disconnectAll', () => { + const conns = manager.connectionManager; + // Does not close pending connections (yet?) + conns.getActiveConnections().forEach(conn => conns.closeConnection(conn, 'command:disconnectAll')); + }); + // sshfs.termninal(target?: string | FileSystemConfig | Connection | vscode.Uri) registerCommandHandler('sshfs.terminal', { promptOptions: { promptConfigs: true, promptConnections: true },