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


TypeScript WhitespaceComputer.changeWhitespaceAfterLineNumber方法代碼示例

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


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

示例1: test

	test('WhitespaceComputer changeWhitespaceAfterLineNumber & getFirstWhitespaceIndexAfterLineNumber', () => {
		var whitespaceComputer = new WhitespaceComputer();

		var a = whitespaceComputer.insertWhitespace(0, 0, 1);
		var b = whitespaceComputer.insertWhitespace(7, 0, 1);
		var c = whitespaceComputer.insertWhitespace(3, 0, 1);

		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(0), a); // 0
		assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(0), 0);
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(1), c); // 3
		assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(1), 3);
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(2), b); // 7
		assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(2), 7);

		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(1), 1); // c
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(2), 1); // c
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(3), 1); // c
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(4), 2); // b
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(5), 2); // b
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(6), 2); // b
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(7), 2); // b
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(8), -1); // --

		// Do not really move a
		whitespaceComputer.changeWhitespaceAfterLineNumber(a, 1);

		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(0), a); // 1
		assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(0), 1);
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(1), c); // 3
		assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(1), 3);
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(2), b); // 7
		assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(2), 7);

		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(1), 0); // a
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(2), 1); // c
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(3), 1); // c
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(4), 2); // b
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(5), 2); // b
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(6), 2); // b
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(7), 2); // b
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(8), -1); // --


		// Do not really move a
		whitespaceComputer.changeWhitespaceAfterLineNumber(a, 2);

		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(0), a); // 2
		assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(0), 2);
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(1), c); // 3
		assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(1), 3);
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(2), b); // 7
		assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(2), 7);

		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(1), 0); // a
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(2), 0); // a
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(3), 1); // c
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(4), 2); // b
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(5), 2); // b
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(6), 2); // b
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(7), 2); // b
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(8), -1); // --


		// Change a to conflict with c => a gets placed after c
		whitespaceComputer.changeWhitespaceAfterLineNumber(a, 3);

		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(0), c); // 3
		assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(0), 3);
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(1), a); // 3
		assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(1), 3);
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(2), b); // 7
		assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(2), 7);

		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(1), 0); // c
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(2), 0); // c
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(3), 0); // c
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(4), 2); // b
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(5), 2); // b
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(6), 2); // b
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(7), 2); // b
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(8), -1); // --


		// Make a no-op
		whitespaceComputer.changeWhitespaceAfterLineNumber(c, 3);

		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(0), c); // 3
		assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(0), 3);
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(1), a); // 3
		assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(1), 3);
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(2), b); // 7
		assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(2), 7);

		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(1), 0); // c
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(2), 0); // c
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(3), 0); // c
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(4), 2); // b
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(5), 2); // b
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(6), 2); // b
		assert.equal(whitespaceComputer.getFirstWhitespaceIndexAfterLineNumber(7), 2); // b
//.........這裏部分代碼省略.........
開發者ID:StateFarmIns,項目名稱:vscode,代碼行數:101,代碼來源:whitespaceComputer.test.ts


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