當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript extHostTypes.TextEdit類代碼示例

本文整理匯總了TypeScript中vs/workbench/api/node/extHostTypes.TextEdit的典型用法代碼示例。如果您正苦於以下問題:TypeScript TextEdit類的具體用法?TypeScript TextEdit怎麽用?TypeScript TextEdit使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了TextEdit類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: test

	test('WorkspaceEdit', function() {

		let a = types.Uri.file('a.ts');
		let b = types.Uri.file('b.ts');

		let edit = new types.WorkspaceEdit();
		assert.ok(!edit.has(a));

		edit.set(a, [types.TextEdit.insert(new types.Position(0, 0), 'fff')]);
		assert.ok(edit.has(a));
		assert.equal(edit.size, 1);
		assertToJSON(edit, [[URI.parse('file:///a.ts').toJSON(), [{ range: [{ line: 0, character: 0 }, { line: 0, character: 0 }], newText: 'fff' }]]]);

		edit.insert(b, new types.Position(1, 1), 'fff');
		edit.delete(b, new types.Range(0, 0, 0, 0));
		assert.ok(edit.has(b));
		assert.equal(edit.size, 2);
		assertToJSON(edit, [
			[URI.parse('file:///a.ts').toJSON(), [{ range: [{ line: 0, character: 0 }, { line: 0, character: 0 }], newText: 'fff' }]],
			[URI.parse('file:///b.ts').toJSON(), [{ range: [{ line: 1, character: 1 }, { line: 1, character: 1 }], newText: 'fff' }, { range: [{ line: 0, character: 0 }, { line: 0, character: 0 }], newText: '' }]]
		]);

		edit.set(b, undefined);
		assert.ok(edit.has(b));
		assert.equal(edit.size, 2);

		edit.set(b, [types.TextEdit.insert(new types.Position(0, 0), 'ffff')]);
		assert.equal(edit.get(b).length, 1);

	});
開發者ID:13572293130,項目名稱:vscode,代碼行數:30,代碼來源:extHostTypes.test.ts

示例2: test

	test('WorkspaceEdit', function() {

		let a = types.Uri.file('a.ts');
		let b = types.Uri.file('b.ts');

		let edit = new types.WorkspaceEdit();
		assert.ok(!edit.has(a));

		edit.set(a, [types.TextEdit.insert(new types.Position(0, 0), 'fff')]);
		assert.ok(edit.has(a));
		assert.equal(edit.size, 1);
		assertToJSON(edit, [['file://a.ts', [{ range: [[0, 0], [0, 0]], newText: 'fff' }]]]);

		edit.insert(b, new types.Position(1, 1), 'fff');
		edit.delete(b, new types.Range(0, 0, 0, 0));
		assert.ok(edit.has(b));
		assert.equal(edit.size, 2);
		assertToJSON(edit, [
			['file://a.ts', [{ range: [[0, 0], [0, 0]], newText: 'fff' }]],
			['file://b.ts', [{ range: [[1, 1], [1, 1]], newText: 'fff' }, { range: [[0, 0], [0, 0]], newText: '' }]]
		]);

		edit.set(b, undefined);
		assert.ok(edit.has(b));
		assert.equal(edit.size, 2);

		edit.set(b, [types.TextEdit.insert(new types.Position(0, 0), 'ffff')]);
		assert.equal(edit.get(b).length, 1);

	});
開發者ID:sangohan,項目名稱:KodeStudio,代碼行數:30,代碼來源:extHostTypes.test.ts

示例3: Position

		let sub2 = participant.onWillSaveTextDocumentEvent(function (e) {
			// the document state AFTER the first listener kicked in
			assert.equal(document.version, 2);
			assert.equal(document.getText(), 'barfoo');

			e.waitUntil(TPromise.as([TextEdit.insert(new Position(0, 0), 'bar')]));
		});
開發者ID:asotog,項目名稱:vscode,代碼行數:7,代碼來源:extHostDocumentSaveParticipant.test.ts

示例4: Position

		let sub = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (e) {

			// concurrent change from somewhere
			documents.$acceptModelChanged(resource.toString(), {
				changes: [{
					range: { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 },
					rangeLength: undefined,
					text: 'bar'
				}],
				eol: undefined,
				versionId: 2
			}, true);

			e.waitUntil(TPromise.as([TextEdit.insert(new Position(0, 0), 'bar')]));
		});
開發者ID:servicesgpr,項目名稱:vscode,代碼行數:15,代碼來源:extHostDocumentSaveParticipant.test.ts


注:本文中的vs/workbench/api/node/extHostTypes.TextEdit類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。