diff --git a/fsprovider-sample/README.md b/fsprovider-sample/README.md index 540eee2f..eab3c985 100644 --- a/fsprovider-sample/README.md +++ b/fsprovider-sample/README.md @@ -9,16 +9,9 @@ This extension implements an in-memory file system to show-case the [filesytem p To *get started* you need this: * install this extension -* have a workspace-file as shown below and open it via 'File > Open Workspace' +* when *not* having a workspace opened, select 'F1 > [MemFS] Setup Workspace' (optionally save the workspace now) * select 'F1 > [MemFs] Create Files' and notice how the explorer is now populated * ... try things out, e.g. IntelliSense in memfs-files, create new files, save them, etc * select 'F1 > [MemFs] Delete Files' or reload to restart -A sample workspace file, saved as `Test.code-workspace`, is this: - -```json -{ - "uri": "memfs:/", - "name": "MemFS" -} -``` +![](./sample.png) diff --git a/fsprovider-sample/package.json b/fsprovider-sample/package.json index 13374630..c748eb4c 100644 --- a/fsprovider-sample/package.json +++ b/fsprovider-sample/package.json @@ -15,11 +15,19 @@ "Other" ], "activationEvents": [ - "onFileSystem:memfs" + "onFileSystem:memfs", + "onCommand:memfs.workspaceInit", + "onCommand:memfs.init", + "onCommand:memfs.reset" ], "main": "./out/src/extension", "contributes": { "commands": [ + { + "command": "memfs.workspaceInit", + "title": "Setup Workspace", + "category": "MemFS" + }, { "command": "memfs.init", "title": "Create Files", @@ -30,7 +38,23 @@ "title": "Delete Files", "category": "MemFS" } - ] + ], + "menus": { + "commandPalette": [ + { + "command": "memfs.init", + "when": "workbenchState == workspace" + }, + { + "command": "memfs.reset", + "when": "workbenchState == workspace" + }, + { + "command": "memfs.workspaceInit", + "when": "workbenchState != workspace" + } + ] + } }, "scripts": { "vscode:prepublish": "npm run compile", diff --git a/fsprovider-sample/sample.png b/fsprovider-sample/sample.png new file mode 100644 index 00000000..bfc03385 Binary files /dev/null and b/fsprovider-sample/sample.png differ diff --git a/fsprovider-sample/src/extension.ts b/fsprovider-sample/src/extension.ts index 4df1206b..299e9f99 100644 --- a/fsprovider-sample/src/extension.ts +++ b/fsprovider-sample/src/extension.ts @@ -6,6 +6,8 @@ import { MemFS } from './fileSystemProvider'; export function activate(context: vscode.ExtensionContext) { + console.log('MemFS says "Hello"') + const memFs = new MemFS(); context.subscriptions.push(vscode.workspace.registerFileSystemProvider('memfs', memFs, { isCaseSensitive: true })); let initialized = false; @@ -52,6 +54,10 @@ export function activate(context: vscode.ExtensionContext) { memFs.writeFile(vscode.Uri.parse(`memfs:/xyz/def/foo.md`), Buffer.from('*MemFS*'), { create: true, overwrite: true }); memFs.writeFile(vscode.Uri.parse(`memfs:/xyz/def/foo.bin`), Buffer.from([0, 0, 0, 1, 7, 0, 0, 1, 1]), { create: true, overwrite: true }); })); + + context.subscriptions.push(vscode.commands.registerCommand('memfs.workspaceInit', _ => { + vscode.workspace.updateWorkspaceFolders(0, 0, { uri: vscode.Uri.parse('memfs:/'), name: "MemFS - Sample" }); + })); } function randomData(lineCnt: number, lineLen = 155): Buffer {