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


TypeScript VerticalObjects.getVerticalOffsetForWhitespaceIndex方法代码示例

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


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

示例1: test

	test('VerticalObjects 1', () => {

		var verticalObjects = new VerticalObjects();

		// Start off with 10 lines
		verticalObjects.replaceLines(10);

		// lines: [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
		// whitespace: -
		assert.equal(verticalObjects.getTotalHeight(10), 100);
		assert.equal(verticalObjects.getVerticalOffsetForLineNumber(1, 10), 0);
		assert.equal(verticalObjects.getVerticalOffsetForLineNumber(2, 10), 10);
		assert.equal(verticalObjects.getVerticalOffsetForLineNumber(3, 10), 20);
		assert.equal(verticalObjects.getVerticalOffsetForLineNumber(4, 10), 30);
		assert.equal(verticalObjects.getVerticalOffsetForLineNumber(5, 10), 40);
		assert.equal(verticalObjects.getVerticalOffsetForLineNumber(6, 10), 50);
		assert.equal(verticalObjects.getVerticalOffsetForLineNumber(7, 10), 60);
		assert.equal(verticalObjects.getVerticalOffsetForLineNumber(8, 10), 70);
		assert.equal(verticalObjects.getVerticalOffsetForLineNumber(9, 10), 80);
		assert.equal(verticalObjects.getVerticalOffsetForLineNumber(10, 10), 90);

		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(0, 10), 1);
		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(1, 10), 1);
		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(5, 10), 1);
		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(9, 10), 1);
		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(10, 10), 2);
		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(11, 10), 2);
		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(15, 10), 2);
		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(19, 10), 2);
		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(20, 10), 3);
		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(21, 10), 3);
		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(29, 10), 3);

		// Add whitespace of height 5px after 2nd line
		verticalObjects.insertWhitespace(2, 0, 5);
		// lines: [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
		// whitespace: a(2,5)
		assert.equal(verticalObjects.getTotalHeight(10), 105);
		assert.equal(verticalObjects.getVerticalOffsetForLineNumber(1, 10), 0);
		assert.equal(verticalObjects.getVerticalOffsetForLineNumber(2, 10), 10);
		assert.equal(verticalObjects.getVerticalOffsetForLineNumber(3, 10), 25);
		assert.equal(verticalObjects.getVerticalOffsetForLineNumber(4, 10), 35);
		assert.equal(verticalObjects.getVerticalOffsetForLineNumber(5, 10), 45);

		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(0, 10), 1);
		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(1, 10), 1);
		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(9, 10), 1);
		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(10, 10), 2);
		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(20, 10), 3);
		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(21, 10), 3);
		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(24, 10), 3);
		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(25, 10), 3);
		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(35, 10), 4);
		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(45, 10), 5);
		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(104, 10), 10);
		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(105, 10), 10);

		// Add two more whitespaces of height 5px
		verticalObjects.insertWhitespace(3, 0, 5);
		verticalObjects.insertWhitespace(4, 0, 5);
		// lines: [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
		// whitespace: a(2,5), b(3, 5), c(4, 5)
		assert.equal(verticalObjects.getTotalHeight(10), 115);
		assert.equal(verticalObjects.getVerticalOffsetForLineNumber(1, 10), 0);
		assert.equal(verticalObjects.getVerticalOffsetForLineNumber(2, 10), 10);
		assert.equal(verticalObjects.getVerticalOffsetForLineNumber(3, 10), 25);
		assert.equal(verticalObjects.getVerticalOffsetForLineNumber(4, 10), 40);
		assert.equal(verticalObjects.getVerticalOffsetForLineNumber(5, 10), 55);
		assert.equal(verticalObjects.getVerticalOffsetForLineNumber(6, 10), 65);

		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(0, 10), 1);
		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(1, 10), 1);
		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(9, 10), 1);
		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(10, 10), 2);
		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(19, 10), 2);
		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(20, 10), 3);
		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(34, 10), 3);
		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(35, 10), 4);
		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(49, 10), 4);
		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(50, 10), 5);
		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(64, 10), 5);
		assert.equal(verticalObjects.getLineNumberAtOrAfterVerticalOffset(65, 10), 6);

		assert.equal(verticalObjects.getVerticalOffsetForWhitespaceIndex(0, 10), 20); // 20 -> 25
		assert.equal(verticalObjects.getVerticalOffsetForWhitespaceIndex(1, 10), 35); // 35 -> 40
		assert.equal(verticalObjects.getVerticalOffsetForWhitespaceIndex(2, 10), 50);

		assert.equal(verticalObjects.getWhitespaceIndexAtOrAfterVerticallOffset(0, 10), 0);
		assert.equal(verticalObjects.getWhitespaceIndexAtOrAfterVerticallOffset(19, 10), 0);
		assert.equal(verticalObjects.getWhitespaceIndexAtOrAfterVerticallOffset(20, 10), 0);
		assert.equal(verticalObjects.getWhitespaceIndexAtOrAfterVerticallOffset(21, 10), 0);
		assert.equal(verticalObjects.getWhitespaceIndexAtOrAfterVerticallOffset(22, 10), 0);
		assert.equal(verticalObjects.getWhitespaceIndexAtOrAfterVerticallOffset(23, 10), 0);
		assert.equal(verticalObjects.getWhitespaceIndexAtOrAfterVerticallOffset(24, 10), 0);
		assert.equal(verticalObjects.getWhitespaceIndexAtOrAfterVerticallOffset(25, 10), 1);
		assert.equal(verticalObjects.getWhitespaceIndexAtOrAfterVerticallOffset(26, 10), 1);
		assert.equal(verticalObjects.getWhitespaceIndexAtOrAfterVerticallOffset(34, 10), 1);
		assert.equal(verticalObjects.getWhitespaceIndexAtOrAfterVerticallOffset(35, 10), 1);
		assert.equal(verticalObjects.getWhitespaceIndexAtOrAfterVerticallOffset(36, 10), 1);
		assert.equal(verticalObjects.getWhitespaceIndexAtOrAfterVerticallOffset(39, 10), 1);
//.........这里部分代码省略.........
开发者ID:pk-codebox-evo,项目名称:ide-microsoft-vscode,代码行数:101,代码来源:verticalObjects.test.ts


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