From cac0ec2fcc3e80139670ba81ac2ab11b646077c9 Mon Sep 17 00:00:00 2001 From: Kelvin Schoofs Date: Thu, 17 Feb 2022 22:56:08 +0100 Subject: [PATCH] Add FS_NOTIFY_ERRORS flag to display notifications for FS errors (fix #282) --- CHANGELOG.md | 3 +++ src/config.ts | 9 +++++++++ src/sshFileSystem.ts | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4867d2..76d22af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ ## Unreleased +### New features +- Add `FS_NOTIFY_ERRORS` flag to display notifications for FS errors (#282) + ### Changes - Small improvements to Dropdown(WithInput) UI components diff --git a/src/config.ts b/src/config.ts index efdf555..f8ed405 100644 --- a/src/config.ts +++ b/src/config.ts @@ -5,6 +5,7 @@ import * as vscode from 'vscode'; import { ConfigLocation, FileSystemConfig, invalidConfigName, parseConnectionString } from './fileSystemConfig'; import { Logging } from './logging'; import { toPromise } from './utils'; +import * as semver from 'semver'; // Logger scope with default warning/error options (which enables stacktraces) disabled const logging = Logging.scope(undefined, false); @@ -385,6 +386,9 @@ function parseFlagList(list: string[] | undefined, origin: string): Record = [value: V, origin: string]; @@ -401,6 +405,11 @@ function calculateFlags(): Record { if ((process.versions as { electron?: string }).electron?.match(/^11\.(0|1|2)\./)) { applyList(['+DF-GE'], 'Fix for issue #239') } + // Starting with 1.56, FileSystemProvider errors aren't shown to the user and just silently fail + // https://github.com/SchoofsKelvin/vscode-sshfs/issues/282 + if (semver.gte(vscode.version, '1.56.0')) { + applyList(['+FS_NOTIFY_ERRORS'], 'Fix for issue #282'); + } applyList(config.globalValue, 'Global Settings'); applyList(config.workspaceValue, 'Workspace Settings'); applyList(config.workspaceFolderValue, 'WorkspaceFolder Settings'); diff --git a/src/sshFileSystem.ts b/src/sshFileSystem.ts index b905680..5e99f37 100644 --- a/src/sshFileSystem.ts +++ b/src/sshFileSystem.ts @@ -3,6 +3,7 @@ import * as path from 'path'; import type * as ssh2 from 'ssh2'; import type * as ssh2s from 'ssh2-streams'; import * as vscode from 'vscode'; +import { getFlagBoolean } from './config'; import type { FileSystemConfig } from './fileSystemConfig'; import { Logger, Logging, LOGGING_NO_STACKTRACE, LOGGING_SINGLE_LINE_STACKTRACE, withStacktraceOffset } from './logging'; @@ -198,6 +199,11 @@ export class SSHFileSystem implements vscode.FileSystemProvider { } if (e !== oldE) Logging.debug(`Error converted to: ${e}`); } + // Display an error notification if the FS_ERROR_NOTIFICATION flag is enabled + const [flagCH] = getFlagBoolean('FS_NOTIFY_ERRORS', true, this.config.flags); + if (flagCH) { + vscode.window.showErrorMessage(`Error handling uri: ${uri}\n${e.message || e}`); + } if (doThrow === true) throw e; if (doThrow) return doThrow(e); }