(text: string, type: string, position: number[])
| 254 | } |
| 255 | |
| 256 | export async function documentNew(text: string, type: string, position: number[]): Promise<void> { |
| 257 | const currentProjectPath = projectPath().path; |
| 258 | if (!currentProjectPath) { |
| 259 | return; // TODO: Report failure |
| 260 | } |
| 261 | const documentUri = Uri.parse('untitled:' + path.join(currentProjectPath, 'new_document.' + type)); |
| 262 | const targetDocument = await workspace.openTextDocument(documentUri); |
| 263 | const edit = new WorkspaceEdit(); |
| 264 | const docLines = targetDocument.lineCount; |
| 265 | edit.replace(documentUri, |
| 266 | targetDocument.validateRange(new Range( |
| 267 | new Position(0, 0), |
| 268 | new Position(docLines + 1, 0) |
| 269 | )), |
| 270 | text); |
| 271 | |
| 272 | void workspace.applyEdit(edit).then(async () => { |
| 273 | const editor = await window.showTextDocument(targetDocument); |
| 274 | editor.selections = [new Selection( |
| 275 | parsePosition(position, targetDocument), |
| 276 | parsePosition(position, targetDocument) |
| 277 | )]; |
| 278 | }); |
| 279 | } |
| 280 | |
| 281 | // interface |
| 282 | // represents addins in a QuickPick menu |
no test coverage detected