From b821bae74d412f78683903eb6d4ac19820eb05c7 Mon Sep 17 00:00:00 2001 From: Kelvin Schoofs Date: Tue, 13 Jul 2021 19:57:26 +0200 Subject: [PATCH] Remove "stale workspace" fix --- CHANGELOG.md | 3 +++ src/fileSystemRouter.ts | 18 ------------------ src/sshFileSystem.ts | 16 ---------------- 3 files changed, 3 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1d41db..6495f57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ ## Unreleased +### Fixes +- Fix remote `code` command (#267) not working without the filesystem already connected (#292) + ### Changes - Proxy hop field now actually lists all known configs to pick from, instead of "TO DO" (#290) diff --git a/src/fileSystemRouter.ts b/src/fileSystemRouter.ts index f7c259d..c962f8d 100644 --- a/src/fileSystemRouter.ts +++ b/src/fileSystemRouter.ts @@ -2,14 +2,6 @@ import * as vscode from 'vscode'; import { Logging } from './logging'; import type { Manager } from './manager'; -function isWorkspaceStale(uri: vscode.Uri) { - for (const folder of vscode.workspace.workspaceFolders || []) { - if (folder.uri.scheme !== 'ssh') continue; - if (folder.uri.authority === uri.authority) return false; - } - return true; -} - export class FileSystemRouter implements vscode.FileSystemProvider { public onDidChangeFile: vscode.Event; protected onDidChangeFileEmitter = new vscode.EventEmitter(); @@ -19,16 +11,6 @@ export class FileSystemRouter implements vscode.FileSystemProvider { public async assertFs(uri: vscode.Uri): Promise { const fs = this.manager.getFs(uri); if (fs) return fs; - // There are some edge cases where vscode tries to access files of a WorkspaceFolder - // that's (being) removed, or it's being added but the window is supposed to reload. - // We only check the first case here - if (isWorkspaceStale(uri)) { - Logging.warning(`Stale workspace for '${uri}', returning empty file system`); - // Throwing an error gives the "${root} ยท Can not resolve workspace folder" - // throw vscode.FileSystemError.Unavailable('Stale workspace'); - // So let's just act as if everything's fine, but there's only the void. - return (await import('./sshFileSystem')).EMPTY_FILE_SYSTEM; - } return this.manager.createFileSystem(uri.authority); } /* FileSystemProvider */ diff --git a/src/sshFileSystem.ts b/src/sshFileSystem.ts index 737bf05..35a34a0 100644 --- a/src/sshFileSystem.ts +++ b/src/sshFileSystem.ts @@ -202,19 +202,3 @@ export class SSHFileSystem implements vscode.FileSystemProvider { if (doThrow) return doThrow(e); } } - -export const EMPTY_FILE_SYSTEM = { - onDidChangeFile: new vscode.EventEmitter().event, - watch: (uri: vscode.Uri, options: { recursive: boolean; excludes: string[]; }) => new vscode.Disposable(() => { }), - stat: (uri: vscode.Uri) => { - console.warn('Checking', uri.toString()); - if (uri.path === '/' || uri.path === '\\') return ({ type: vscode.FileType.Directory }) as vscode.FileStat; - throw vscode.FileSystemError.FileNotFound(uri); - }, - readDirectory: (uri: vscode.Uri) => [], - createDirectory: (uri: vscode.Uri) => { }, - readFile: (uri: vscode.Uri) => new Uint8Array(0), - writeFile: (uri: vscode.Uri, content: Uint8Array, options: { create: boolean; overwrite: boolean; }) => { }, - delete: (uri: vscode.Uri, options: { recursive: boolean; }) => { }, - rename: (oldUri: vscode.Uri, newUri: vscode.Uri, options: { overwrite: boolean; }) => { }, -} as vscode.FileSystemProvider;