From 68217ba392cd2279975bd2c8bbaeceae734ba121 Mon Sep 17 00:00:00 2001 From: kieferrm Date: Mon, 15 Jul 2019 14:44:04 -0700 Subject: [PATCH] individual file handling --- fsprovider-sample/README.md | 3 +++ fsprovider-sample/package.json | 18 ++++++++++++++++++ fsprovider-sample/src/extension.ts | 12 ++++++++++++ 3 files changed, 33 insertions(+) diff --git a/fsprovider-sample/README.md b/fsprovider-sample/README.md index dbb35568..51272445 100644 --- a/fsprovider-sample/README.md +++ b/fsprovider-sample/README.md @@ -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) diff --git a/fsprovider-sample/package.json b/fsprovider-sample/package.json index 8e4f623f..81a9e789 100644 --- a/fsprovider-sample/package.json +++ b/fsprovider-sample/package.json @@ -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" diff --git a/fsprovider-sample/src/extension.ts b/fsprovider-sample/src/extension.ts index a537cf28..563b70a9 100644 --- a/fsprovider-sample/src/extension.ts +++ b/fsprovider-sample/src/extension.ts @@ -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;