From bbba8b728082481f253a47323004be6ffc2715be Mon Sep 17 00:00:00 2001 From: Kelvin Schoofs Date: Wed, 8 Jul 2020 19:57:47 +0200 Subject: [PATCH] Slight improvements/fixes --- src/config.ts | 1 + src/extension.ts | 14 +++++++------- src/logging.ts | 7 ++++++- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/config.ts b/src/config.ts index 32fb3cf..635809b 100644 --- a/src/config.ts +++ b/src/config.ts @@ -287,6 +287,7 @@ export function getConfig(name: string) { function valueMatches(a: any, b: any): boolean { if (typeof a !== typeof b) return false; if (typeof a !== 'object') return a === b; + if (!a || !b) return a === b; if (Array.isArray(a)) { if (!Array.isArray(b)) return false; if (a.length !== b.length) return false; diff --git a/src/extension.ts b/src/extension.ts index b5823a9..788b65f 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -56,19 +56,19 @@ export function activate(context: vscode.ExtensionContext) { subscribe(vscode.window.createTreeView('sshfs-configs', { treeDataProvider: manager, showCollapseAll: true })); subscribe(vscode.tasks.registerTaskProvider('ssh-shell', manager)); - async function pickAndClick(func: (name: string) => void, name?: string, activeOrNot?: boolean) { + async function pickAndClick(func: (name: string | FileSystemConfig) => void, name?: string | FileSystemConfig, activeOrNot?: boolean) { name = name || await pickConfig(manager, activeOrNot); if (name) func.call(manager, name); } - registerCommand('sshfs.new', async () => manager.openSettings({ type: 'newconfig' })); + registerCommand('sshfs.new', () => manager.openSettings({ type: 'newconfig' })); registerCommand('sshfs.settings', () => manager.openSettings()); - registerCommand('sshfs.connect', (name?: string) => pickAndClick(manager.commandConnect, name, false)); - registerCommand('sshfs.disconnect', (name?: string) => pickAndClick(manager.commandDisconnect, name, true)); - registerCommand('sshfs.reconnect', (name?: string) => pickAndClick(manager.commandReconnect, name, true)); - registerCommand('sshfs.terminal', (name?: string) => pickAndClick(manager.commandTerminal, name)); - registerCommand('sshfs.configure', (name?: string) => pickAndClick(manager.commandConfigure, name)); + registerCommand('sshfs.connect', (name?: string | FileSystemConfig) => pickAndClick(manager.commandConnect, name, false)); + registerCommand('sshfs.disconnect', (name?: string | FileSystemConfig) => pickAndClick(manager.commandDisconnect, name, true)); + registerCommand('sshfs.reconnect', (name?: string | FileSystemConfig) => pickAndClick(manager.commandReconnect, name, true)); + registerCommand('sshfs.terminal', (name?: string | FileSystemConfig) => pickAndClick(manager.commandTerminal, name)); + registerCommand('sshfs.configure', (name?: string | FileSystemConfig) => pickAndClick(manager.commandConfigure, name)); registerCommand('sshfs.reload', loadConfigs); } diff --git a/src/logging.ts b/src/logging.ts index 0aba866..c582b9b 100644 --- a/src/logging.ts +++ b/src/logging.ts @@ -100,12 +100,17 @@ class Logger { } } -export function censorConfig(config: FileSystemConfig): FileSystemConfig { +export interface CensoredFileSystemConfig extends Omit { + sock?: string; +} + +export function censorConfig(config: FileSystemConfig): CensoredFileSystemConfig { return { ...config, password: typeof config.password === 'string' ? '' : config.password, passphrase: typeof config.passphrase === 'string' ? '' : config.passphrase, privateKey: config.privateKey instanceof Buffer ? `Buffer(${config.privateKey.length})` : config.privateKey, + sock: config.sock ? '' : config.sock, }; }