add a command to setup a workspace

This commit is contained in:
Johannes Rieken
2018-04-26 18:27:16 +02:00
parent b67adbb3f9
commit c77406222c
4 changed files with 34 additions and 11 deletions

View File

@ -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)

View File

@ -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",

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

View File

@ -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 {