|
|
@ -58,14 +58,10 @@ export class Manager implements vscode.FileSystemProvider, vscode.TreeDataProvid
|
|
|
|
constructor(public readonly context: vscode.ExtensionContext) {
|
|
|
|
constructor(public readonly context: vscode.ExtensionContext) {
|
|
|
|
this.onDidChangeFile = this.onDidChangeFileEmitter.event;
|
|
|
|
this.onDidChangeFile = this.onDidChangeFileEmitter.event;
|
|
|
|
this.onDidChangeTreeData = this.onDidChangeTreeDataEmitter.event;
|
|
|
|
this.onDidChangeTreeData = this.onDidChangeTreeDataEmitter.event;
|
|
|
|
const folderAdded = async (folder: vscode.WorkspaceFolder) => {
|
|
|
|
// In a multi-workspace environment, when the non-main folder gets removed,
|
|
|
|
if (folder.uri.scheme !== 'ssh') return;
|
|
|
|
// it might be one of ours, which we should then disconnect
|
|
|
|
this.createFileSystem(folder.uri.authority);
|
|
|
|
// When one gets added, it gets connected on-demand (using stat() etc)
|
|
|
|
};
|
|
|
|
|
|
|
|
const folders = vscode.workspace.workspaceFolders || [];
|
|
|
|
|
|
|
|
folders.forEach(folderAdded);
|
|
|
|
|
|
|
|
vscode.workspace.onDidChangeWorkspaceFolders((e) => {
|
|
|
|
vscode.workspace.onDidChangeWorkspaceFolders((e) => {
|
|
|
|
e.added.forEach(folderAdded);
|
|
|
|
|
|
|
|
e.removed.forEach(async (folder) => {
|
|
|
|
e.removed.forEach(async (folder) => {
|
|
|
|
if (folder.uri.scheme !== 'ssh') return;
|
|
|
|
if (folder.uri.scheme !== 'ssh') return;
|
|
|
|
this.commandDisconnect(folder.uri.authority);
|
|
|
|
this.commandDisconnect(folder.uri.authority);
|
|
|
@ -101,9 +97,9 @@ export class Manager implements vscode.FileSystemProvider, vscode.TreeDataProvid
|
|
|
|
if (existing) return existing;
|
|
|
|
if (existing) return existing;
|
|
|
|
let promise = this.creatingFileSystems[name];
|
|
|
|
let promise = this.creatingFileSystems[name];
|
|
|
|
if (promise) return promise;
|
|
|
|
if (promise) return promise;
|
|
|
|
config = config || (await loadConfigs()).find(c => c.name === name);
|
|
|
|
|
|
|
|
promise = catchingPromise<SSHFileSystem>(async (resolve, reject) => {
|
|
|
|
promise = catchingPromise<SSHFileSystem>(async (resolve, reject) => {
|
|
|
|
const { createSSH, getSFTP, calculateActualConfig } = await import('./connect');
|
|
|
|
const { createSSH, getSFTP, calculateActualConfig } = await import('./connect');
|
|
|
|
|
|
|
|
config = config || (await loadConfigs()).find(c => c.name === name);
|
|
|
|
config = config && await calculateActualConfig(config) || undefined;
|
|
|
|
config = config && await calculateActualConfig(config) || undefined;
|
|
|
|
if (!config) {
|
|
|
|
if (!config) {
|
|
|
|
throw new Error(`A SSH filesystem with the name '${name}' doesn't exist`);
|
|
|
|
throw new Error(`A SSH filesystem with the name '${name}' doesn't exist`);
|
|
|
|