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


TypeScript VerticalObjects.getWhitespaceIndexAtOrAfterVerticallOffset方法代碼示例

本文整理匯總了TypeScript中vs/editor/common/viewLayout/verticalObjects.VerticalObjects.getWhitespaceIndexAtOrAfterVerticallOffset方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript VerticalObjects.getWhitespaceIndexAtOrAfterVerticallOffset方法的具體用法?TypeScript VerticalObjects.getWhitespaceIndexAtOrAfterVerticallOffset怎麽用?TypeScript VerticalObjects.getWhitespaceIndexAtOrAfterVerticallOffset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在vs/editor/common/viewLayout/verticalObjects.VerticalObjects的用法示例。


在下文中一共展示了VerticalObjects.getWhitespaceIndexAtOrAfterVerticallOffset方法的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.getWhitespaceIndexAtOrAfterVerticallOffset方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。