diff --git a/src/config.ts b/src/config.ts index d13f4ea..4109840 100644 --- a/src/config.ts +++ b/src/config.ts @@ -206,8 +206,8 @@ export async function alterConfigs(location: ConfigLocation, alterer: ConfigAlte case vscode.ConfigurationTarget.WorkspaceFolder: const conf = vscode.workspace.getConfiguration('sshfs'); const inspect = conf.inspect('configs')!; - const array = [[], inspect.globalValue, inspect.workspaceValue, inspect.workspaceFolderValue][location]; - if (!array) throw new Error(`Something very unexpected happened...`); + // If the array doesn't exist, create a new empty one + const array = [, inspect.globalValue, inspect.workspaceValue, inspect.workspaceFolderValue][location] || []; let modified = alterer(array); if (!modified) return; modified = modified.map((config) => { diff --git a/src/fileSystemConfig.ts b/src/fileSystemConfig.ts index d80e09a..17d3e97 100644 --- a/src/fileSystemConfig.ts +++ b/src/fileSystemConfig.ts @@ -17,7 +17,8 @@ export function formatConfigLocation(location?: ConfigLocation): string { } export function getLocations(configs: FileSystemConfig[]): ConfigLocation[] { - const res: ConfigLocation[] = [1, 2, 3]; + const res: ConfigLocation[] = [1, 2 /*, 3*/]; // No WorkspaceFolder support (for now) + // TODO: Suggest creating sshfs.jsonc etc in current workspace folder(s) (UI feature?) for (const { _location } of configs) { if (!_location) continue; if (!res.find(l => l === _location)) {