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


TypeScript highlightedLabel.HighlightedLabel类代码示例

本文整理汇总了TypeScript中vs/base/browser/ui/highlightedlabel/highlightedLabel.HighlightedLabel的典型用法代码示例。如果您正苦于以下问题:TypeScript HighlightedLabel类的具体用法?TypeScript HighlightedLabel怎么用?TypeScript HighlightedLabel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test

	test('escapeNewLines', () => {

		let highlights = [{ start: 0, end: 5 }, { start: 7, end: 9 }, { start: 11, end: 12 }];// before,after,after
		let escaped = HighlightedLabel.escapeNewLines('ACTION\r\n_TYPE2', highlights);
		assert.equal(escaped, 'ACTION\u23CE_TYPE2');
		assert.deepEqual(highlights, [{ start: 0, end: 5 }, { start: 6, end: 8 }, { start: 10, end: 11 }]);

		highlights = [{ start: 5, end: 9 }, { start: 11, end: 12 }];//overlap,after
		escaped = HighlightedLabel.escapeNewLines('ACTION\r\n_TYPE2', highlights);
		assert.equal(escaped, 'ACTION\u23CE_TYPE2');
		assert.deepEqual(highlights, [{ start: 5, end: 8 }, { start: 10, end: 11 }]);

	});
开发者ID:KTXSoftware,项目名称:KodeStudio,代码行数:13,代码来源:highlightedLabel.test.ts

示例2: suite

suite('HighlightedLabel', () => {
	let label: HighlightedLabel;

	setup(() => {
		label = new HighlightedLabel(document.createElement('div'), true);
	});

	teardown(() => {
		label.dispose();
		label = null;
	});

	test('empty label', function () {
		assert.equal(label.element.innerHTML, '');
	});

	test('no decorations', function () {
		label.set('hello');
		assert.equal(label.element.innerHTML, '<span>hello</span>');
	});

	test('escape html', function () {
		label.set('hel<lo');
		assert.equal(label.element.innerHTML, '<span>hel&lt;lo</span>');
	});

	test('everything highlighted', function () {
		label.set('hello', [{ start: 0, end: 5 }]);
		assert.equal(label.element.innerHTML, '<span class="highlight">hello</span>');
	});

	test('beginning highlighted', function () {
		label.set('hellothere', [{ start: 0, end: 5 }]);
		assert.equal(label.element.innerHTML, '<span class="highlight">hello</span><span>there</span>');
	});

	test('ending highlighted', function () {
		label.set('goodbye', [{ start: 4, end: 7 }]);
		assert.equal(label.element.innerHTML, '<span>good</span><span class="highlight">bye</span>');
	});

	test('middle highlighted', function () {
		label.set('foobarfoo', [{ start: 3, end: 6 }]);
		assert.equal(label.element.innerHTML, '<span>foo</span><span class="highlight">bar</span><span>foo</span>');
	});

	test('escapeNewLines', () => {

		let highlights = [{ start: 0, end: 5 }, { start: 7, end: 9 }, { start: 11, end: 12 }];// before,after,after
		let escaped = HighlightedLabel.escapeNewLines('ACTION\r\n_TYPE2', highlights);
		assert.equal(escaped, 'ACTION\u23CE_TYPE2');
		assert.deepEqual(highlights, [{ start: 0, end: 5 }, { start: 6, end: 8 }, { start: 10, end: 11 }]);

		highlights = [{ start: 5, end: 9 }, { start: 11, end: 12 }];//overlap,after
		escaped = HighlightedLabel.escapeNewLines('ACTION\r\n_TYPE2', highlights);
		assert.equal(escaped, 'ACTION\u23CE_TYPE2');
		assert.deepEqual(highlights, [{ start: 5, end: 8 }, { start: 10, end: 11 }]);

	});
});
开发者ID:KTXSoftware,项目名称:KodeStudio,代码行数:60,代码来源:highlightedLabel.test.ts

示例3: suite

suite('HighlightedLabel', () => {
	var label: HighlightedLabel;

	setup(() => {
		label = new HighlightedLabel(document.createElement('div'));
	});

	teardown(() => {
		label.dispose();
		label = null;
	});

	test('empty label', function() {
		assert.equal(label.element.innerHTML, '');
	});

	test('no decorations', function() {
		label.set('hello');
		assert.equal(label.element.innerHTML, '<span>hello</span>');
	});

	test('escape html', function() {
		label.set('hel<lo');
		assert.equal(label.element.innerHTML, '<span>hel&lt;lo</span>');
	});

	test('everything highlighted', function() {
		label.set('hello', [ { start: 0, end: 5 } ]);
		assert.equal(label.element.innerHTML, '<span class="highlight">hello</span>');
	});

	test('beginning highlighted', function() {
		label.set('hellothere', [ { start: 0, end: 5 } ]);
		assert.equal(label.element.innerHTML, '<span class="highlight">hello</span><span>there</span>');
	});

	test('ending highlighted', function() {
		label.set('goodbye', [ { start: 4, end: 7 } ]);
		assert.equal(label.element.innerHTML, '<span>good</span><span class="highlight">bye</span>');
	});

	test('middle highlighted', function() {
		label.set('foobarfoo', [ { start: 3, end: 6 } ]);
		assert.equal(label.element.innerHTML, '<span>foo</span><span class="highlight">bar</span><span>foo</span>');
	});
});
开发者ID:13572293130,项目名称:vscode,代码行数:46,代码来源:highlightedLabel.test.ts

示例4: suite

suite("HighlightedLabel", () => {
	var label: HighlightedLabel;

	setup(() => {
		label = new HighlightedLabel(document.createElement('div'));
	});

	teardown(() => {
		label.dispose();
		label = null;
	});

	test("empty label", function() {
		assert.equal(label.element.innerHTML, "");
	});

	test("no decorations", function() {
		label.set("hello");
		assert.equal(label.element.innerHTML, "<span>hello</span>");
	});

	test("escape html", function() {
		label.set("hel<lo");
		assert.equal(label.element.innerHTML, "<span>hel&lt;lo</span>");
	});

	test("everything highlighted", function() {
		label.set("hello", [ { start: 0, end: 5 } ]);
		assert.equal(label.element.innerHTML, '<span class="highlight">hello</span>');
	});

	test("beginning highlighted", function() {
		label.set("hellothere", [ { start: 0, end: 5 } ]);
		assert.equal(label.element.innerHTML, '<span class="highlight">hello</span><span>there</span>');
	});

	test("ending highlighted", function() {
		label.set("goodbye", [ { start: 4, end: 7 } ]);
		assert.equal(label.element.innerHTML, '<span>good</span><span class="highlight">bye</span>');
	});

	test("middle highlighted", function() {
		label.set("foobarfoo", [ { start: 3, end: 6 } ]);
		assert.equal(label.element.innerHTML, '<span>foo</span><span class="highlight">bar</span><span>foo</span>');
	});
});
开发者ID:amamut,项目名称:vscode,代码行数:46,代码来源:highlightedLabel.test.ts

示例5: function

	test('middle highlighted', function () {
		label.set('foobarfoo', [{ start: 3, end: 6 }]);
		assert.equal(label.element.innerHTML, '<span>foo</span><span class="highlight">bar</span><span>foo</span>');
	});
开发者ID:KTXSoftware,项目名称:KodeStudio,代码行数:4,代码来源:highlightedLabel.test.ts

示例6:

	teardown(() => {
		label.dispose();
		label = null;
	});
开发者ID:KTXSoftware,项目名称:KodeStudio,代码行数:4,代码来源:highlightedLabel.test.ts


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