aboutsummaryrefslogtreecommitdiff
path: root/code/src/extension.ts
diff options
context:
space:
mode:
Diffstat (limited to 'code/src/extension.ts')
-rw-r--r--code/src/extension.ts29
1 files changed, 25 insertions, 4 deletions
diff --git a/code/src/extension.ts b/code/src/extension.ts
index 81153b7e6..3b24b73b6 100644
--- a/code/src/extension.ts
+++ b/code/src/extension.ts
@@ -113,12 +113,26 @@ export function activate(context: vscode.ExtensionContext) {
113 return await vscode.tasks.executeTask(task) 113 return await vscode.tasks.executeTask(task)
114 } 114 }
115 }) 115 })
116 registerCommand('libsyntax-rust.createFile', async (uri_: string) => { 116 registerCommand('libsyntax-rust.fsEdit', async (ops: FsOp[]) => {
117 let uri = vscode.Uri.parse(uri_)
118 let edit = new vscode.WorkspaceEdit() 117 let edit = new vscode.WorkspaceEdit()
119 edit.createFile(uri) 118 let created;
119 let moved;
120 for (let op of ops) {
121 if (op.type == "createFile") {
122 let uri = vscode.Uri.parse(op.uri!)
123 edit.createFile(uri)
124 created = uri
125 } else if (op.type == "moveFile") {
126 let src = vscode.Uri.parse(op.src!)
127 let dst = vscode.Uri.parse(op.dst!)
128 edit.renameFile(src, dst)
129 moved = dst
130 } else {
131 console.error(`unknown op: ${JSON.stringify(op)}`)
132 }
133 }
120 await vscode.workspace.applyEdit(edit) 134 await vscode.workspace.applyEdit(edit)
121 let doc = await vscode.workspace.openTextDocument(uri) 135 let doc = await vscode.workspace.openTextDocument((created || moved)!)
122 await vscode.window.showTextDocument(doc) 136 await vscode.window.showTextDocument(doc)
123 }) 137 })
124 138
@@ -368,3 +382,10 @@ function createTask(spec: Runnable): vscode.Task {
368 let t = new vscode.Task(definition, f, definition.label, TASK_SOURCE, exec, ['$rustc']); 382 let t = new vscode.Task(definition, f, definition.label, TASK_SOURCE, exec, ['$rustc']);
369 return t; 383 return t;
370} 384}
385
386interface FsOp {
387 type: string;
388 uri?: string;
389 src?: string;
390 dst?: string;
391}