individual file handling

This commit is contained in:
kieferrm
2019-07-15 14:44:04 -07:00
parent 5fc83ec28b
commit 68217ba392
3 changed files with 33 additions and 0 deletions

View File

@ -12,6 +12,9 @@ To *get started* you need this:
* 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
* open `file.txt` and make changes
* 'F1 > [MemFS] Delete "file.txt', observe that the editor is now indicating that the file is deleted
* 'F1 > [MemFS] Add "file.txt', observe that the editor content is reset and the '(delete)' annotation disappeard
* select 'F1 > [MemFs] Delete Files' or reload to restart
![sample screenshot](https://github.com/Microsoft/vscode-extension-samples/raw/master/fsprovider-sample/sample.png)

View File

@ -37,6 +37,16 @@
"command": "memfs.reset",
"title": "Delete Files",
"category": "MemFS"
},
{
"command": "memfs.deleteFile",
"title": "Delete \"file.txt\"",
"category": "MemFS"
},
{
"command": "memfs.addFile",
"title": "Add \"file.txt\"",
"category": "MemFS"
}
],
"menus": {
@ -49,6 +59,14 @@
"command": "memfs.reset",
"when": "workbenchState == workspace"
},
{
"command": "memfs.deleteFile",
"when": "workbenchState == workspace"
},
{
"command": "memfs.addFile",
"when": "workbenchState == workspace"
},
{
"command": "memfs.workspaceInit",
"when": "workbenchState != workspace"

View File

@ -18,6 +18,18 @@ export function activate(context: vscode.ExtensionContext) {
initialized = false;
}));
context.subscriptions.push(vscode.commands.registerCommand('memfs.addFile', _ => {
if (initialized) {
memFs.writeFile(vscode.Uri.parse(`memfs:/file.txt`), Buffer.from('foo'), { create: true, overwrite: true });
}
}));
context.subscriptions.push(vscode.commands.registerCommand('memfs.deleteFile', _ => {
if (initialized) {
memFs.delete(vscode.Uri.parse('memfs:/file.txt'));
}
}));
context.subscriptions.push(vscode.commands.registerCommand('memfs.init', _ => {
if (initialized) {
return;