mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-04-27 16:55:44 +08:00
individual file handling
This commit is contained in:
@ -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
|
||||
|
||||

|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user