当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript workspace.openTextDocument方法代码示例

本文整理汇总了TypeScript中vscode.workspace.openTextDocument方法的典型用法代码示例。如果您正苦于以下问题:TypeScript workspace.openTextDocument方法的具体用法?TypeScript workspace.openTextDocument怎么用?TypeScript workspace.openTextDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vscode.workspace的用法示例。


在下文中一共展示了workspace.openTextDocument方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: test

    test('class methods', async () => {
        if (!await isPython3) {
            return;
        }
        let textDocument = await vscode.workspace.openTextDocument(filePep526);
        await vscode.window.showTextDocument(textDocument);
        assert(vscode.window.activeTextEditor, 'No active editor');
        let position = new vscode.Position(20, 4);
        let list = await vscode.commands.executeCommand<vscode.CompletionList>('vscode.executeCompletionItemProvider', textDocument.uri, position);
        assert.notEqual(list.items.filter(item => item.label === 'a').length, 0, 'method a not found');

        position = new vscode.Position(21, 4);
        list = await vscode.commands.executeCommand<vscode.CompletionList>('vscode.executeCompletionItemProvider', textDocument.uri, position);
        assert.notEqual(list.items.filter(item => item.label === 'b').length, 0, 'method b not found');
    });
开发者ID:,项目名称:,代码行数:15,代码来源:

示例2: test

 test('Get Code Block (for in)', done => {
     let textDocument: vscode.TextDocument;
     return vscode.workspace.openTextDocument(FILE_WITH_CELLS).then(document => {
         textDocument = document;
         return vscode.window.showTextDocument(textDocument);
     }).then(editor => {
         assert(vscode.window.activeTextEditor, 'No active editor');
         editor.selection = new vscode.Selection(16, 0, 16, 0);
         return codeHelper.getSelectedCode().then(code => {
             const end = textDocument.lineAt(18).range.end;
             const start = editor.selection.start;
             assert.equal(code, textDocument.getText(new vscode.Range(start, end)), 'Text is not the same');
         });
     }).then(done, done);
 });
开发者ID:walkoncross,项目名称:pythonVSCode,代码行数:15,代码来源:extension.jupyter.comms.jupyter.codeHelper.test.ts

示例3: showSource

function showSource(mdUri: vscode.Uri) {
	if (!mdUri) {
		return vscode.commands.executeCommand('workbench.action.navigateBack');
	}

	const docUri = vscode.Uri.parse(mdUri.query);
	for (const editor of vscode.window.visibleTextEditors) {
		if (editor.document.uri.toString() === docUri.toString()) {
			return vscode.window.showTextDocument(editor.document, editor.viewColumn);
		}
	}

	return vscode.workspace.openTextDocument(docUri)
		.then(vscode.window.showTextDocument);
}
开发者ID:yuit,项目名称:vscode,代码行数:15,代码来源:extension.ts

示例4: test

        test('should correctly format ' + path.basename(inFile), () => {
            let expectedText = fs.readFileSync(outFile);
            let textDocument: vscode.TextDocument;

            return vscode.workspace.openTextDocument(inFile).then(document => {
                textDocument = document;
                return formatService.provideDocumentFormattingEdits(document);
            }).then(edits => {
                let workspaceEdit = new vscode.WorkspaceEdit();
                workspaceEdit.set(textDocument.uri, edits);
                return vscode.workspace.applyEdit(workspaceEdit);
            }).then(() => {
                assert.equal(textDocument.getText(), expectedText);
            });
        });
开发者ID:JohanSJA,项目名称:RustyCode,代码行数:15,代码来源:formatService.test.ts

示例5: openFileInEditor

  // Open the created component in the editor
  public openFileInEditor(folderName): Q.Promise<TextEditor> {
    const deferred: Q.Deferred<TextEditor> = Q.defer<TextEditor>();
    var inputName: string = path.parse(folderName).name;;
    var fullFilePath: string = path.join(folderName, `${inputName}.component.ts`);

    workspace.openTextDocument(fullFilePath).then((textDocument) => {
      if (!textDocument) { return; }
      window.showTextDocument(textDocument).then((editor) => {
        if (!editor) { return; }
        deferred.resolve(editor);
      });
    });

    return deferred.promise;
  }
开发者ID:sebastianbaar,项目名称:vscode-add-angular2-files,代码行数:16,代码来源:add-files.ts

示例6: test

	test('editor, assign and check view columns', () => {

		return workspace.openTextDocument(join(workspace.rootPath, './far.js')).then(doc => {
			let p1 = window.showTextDocument(doc, ViewColumn.One).then(editor => {
				assert.equal(editor.viewColumn, ViewColumn.One);
			});
			let p2 = window.showTextDocument(doc, ViewColumn.Two).then(editor => {
				assert.equal(editor.viewColumn, ViewColumn.Two);
			});
			let p3 = window.showTextDocument(doc, ViewColumn.Three).then(editor => {
				assert.equal(editor.viewColumn, ViewColumn.Three);
			});
			return Promise.all([p1, p2, p3]);
		});
	});
开发者ID:douglaseccker,项目名称:vscode,代码行数:15,代码来源:window.test.ts

示例7: onExecute

				execute: () => {
					this._client.logTelemetry('js.hintProjectExcludes.accepted');
					onExecute();
					this._item.hide();

					let configFileUri: vscode.Uri;
					if (vscode.workspace.rootPath && dirname(configFileName).indexOf(vscode.workspace.rootPath) === 0) {
						configFileUri = vscode.Uri.file(configFileName);
					} else {
						configFileUri = vscode.Uri.parse('untitled://' + join(vscode.workspace.rootPath || '', 'jsconfig.json'));
					}

					return vscode.workspace.openTextDocument(configFileName)
						.then(vscode.window.showTextDocument);
				}
开发者ID:m-khosravi,项目名称:vscode,代码行数:15,代码来源:projectStatus.ts

示例8:

	context.subscriptions.push(vscode.commands.registerCommand('_markdown.didClick', (uri: string, line) => {
		const sourceUri = vscode.Uri.parse(decodeURIComponent(uri));
		return vscode.workspace.openTextDocument(sourceUri)
			.then(document => vscode.window.showTextDocument(document))
			.then(editor =>
				vscode.commands.executeCommand('revealLine', { lineNumber: Math.floor(line), at: 'center' })
					.then(() => editor))
			.then(editor => {
				if (editor) {
					editor.selection = new vscode.Selection(
						new vscode.Position(Math.floor(line), 0),
						new vscode.Position(Math.floor(line), 0));
				}
			});
	}));
开发者ID:kieferrm,项目名称:vscode,代码行数:15,代码来源:extension.ts

示例9: createRandomFile

	return createRandomFile(initialContents).then(file => {
		return vscode.workspace.openTextDocument(file).then(doc => {
			return vscode.window.showTextDocument(doc).then((editor) => {
				return run(editor, doc).then(_ => {
					if (doc.isDirty) {
						return doc.save().then(saved => {
							return deleteFile(file);
						});
					} else {
						return deleteFile(file);
					}
				});
			});
		});
	});
开发者ID:vnvizitiu,项目名称:vscode,代码行数:15,代码来源:testUtils.ts

示例10: openFile

	@command('git.openFile')
	async openFile(arg?: Resource | Uri, ...resourceStates: SourceControlResourceState[]): Promise<void> {
		const preserveFocus = arg instanceof Resource;

		let uris: Uri[] | undefined;

		if (arg instanceof Uri) {
			if (arg.scheme === 'git') {
				uris = [Uri.file(fromGitUri(arg).path)];
			} else if (arg.scheme === 'file') {
				uris = [arg];
			}
		} else {
			let resource = arg;

			if (!(resource instanceof Resource)) {
				// can happen when called from a keybinding
				resource = this.getSCMResource();
			}

			if (resource) {
				uris = [...resourceStates.map(r => r.resourceUri), resource.resourceUri];
			}
		}

		if (!uris) {
			return;
		}

		const preview = uris.length === 1 ? true : false;
		const activeTextEditor = window.activeTextEditor;
		for (const uri of uris) {
			const opts: TextDocumentShowOptions = {
				preserveFocus,
				preview,
				viewColumn: ViewColumn.Active
			};

			// Check if active text editor has same path as other editor. we cannot compare via
			// URI.toString() here because the schemas can be different. Instead we just go by path.
			if (activeTextEditor && activeTextEditor.document.uri.path === uri.path) {
				opts.selection = activeTextEditor.selection;
			}

			const document = await workspace.openTextDocument(uri);
			await window.showTextDocument(document, opts);
		}
	}
开发者ID:golf1052,项目名称:vscode,代码行数:48,代码来源:commands.ts


注:本文中的vscode.workspace.openTextDocument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。