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


TypeScript WhitespaceComputer.changeAfterLineNumberForWhitespace方法代码示例

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


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

示例1: test

	test('WhitespaceComputer changeAfterLineNumberForWhitespace & 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.changeAfterLineNumberForWhitespace(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.changeAfterLineNumberForWhitespace(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.changeAfterLineNumberForWhitespace(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.changeAfterLineNumberForWhitespace(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:BMGburger,项目名称:vscode,代码行数:101,代码来源:whitespaceComputer.test.ts

示例2: changeAfterLineNumberForWhitespace

	/**
	 * Change the line number after which an existing whitespace flows.
	 *
	 * @param id The whitespace to change
	 * @param newAfterLineNumber The new line number the whitespace will follow
	 * @return Returns true if the whitespace is found and if the new line number is different than the old line number
	 */
	public changeAfterLineNumberForWhitespace(id:number, newAfterLineNumber:number): boolean {
		return this.whitespaces.changeAfterLineNumberForWhitespace(id, newAfterLineNumber);
	}
开发者ID:1424667164,项目名称:vscode,代码行数:10,代码来源:verticalObjects.ts


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