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


TypeScript WhitespaceComputer.onModelLinesDeleted方法代码示例

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


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

示例1: test


//.........这里部分代码省略.........
		assert.equal(whitespaceComputer.getHeightForWhitespaceIndex(3), 20);
		assert.equal(whitespaceComputer.getAccumulatedHeight(0), 50);
		assert.equal(whitespaceComputer.getAccumulatedHeight(1), 150);
		assert.equal(whitespaceComputer.getAccumulatedHeight(2), 180);
		assert.equal(whitespaceComputer.getAccumulatedHeight(3), 200);
		assert.equal(whitespaceComputer.getTotalHeight(), 200);
		assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(1), 50);
		assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(2), 50);
		assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(3), 150);
		assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(4), 180);
		assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(5), 200);

		// Remove whitespace after line 2
		whitespaceComputer.removeWhitespace(a);
		// whitespaces: b(0, 50), d(3, 30), c(4, 20)
		assert.equal(whitespaceComputer.getCount(), 3);
		assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(0), 0);
		assert.equal(whitespaceComputer.getHeightForWhitespaceIndex(0), 50);
		assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(1), 3);
		assert.equal(whitespaceComputer.getHeightForWhitespaceIndex(1), 30);
		assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(2), 4);
		assert.equal(whitespaceComputer.getHeightForWhitespaceIndex(2), 20);
		assert.equal(whitespaceComputer.getAccumulatedHeight(0), 50);
		assert.equal(whitespaceComputer.getAccumulatedHeight(1), 80);
		assert.equal(whitespaceComputer.getAccumulatedHeight(2), 100);
		assert.equal(whitespaceComputer.getTotalHeight(), 100);
		assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(1), 50);
		assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(2), 50);
		assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(3), 50);
		assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(4), 80);
		assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(5), 100);

		// Remove whitespace before line 1
		whitespaceComputer.removeWhitespace(b);
		// whitespaces: d(3, 30), c(4, 20)
		assert.equal(whitespaceComputer.getCount(), 2);
		assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(0), 3);
		assert.equal(whitespaceComputer.getHeightForWhitespaceIndex(0), 30);
		assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(1), 4);
		assert.equal(whitespaceComputer.getHeightForWhitespaceIndex(1), 20);
		assert.equal(whitespaceComputer.getAccumulatedHeight(0), 30);
		assert.equal(whitespaceComputer.getAccumulatedHeight(1), 50);
		assert.equal(whitespaceComputer.getTotalHeight(), 50);
		assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(1), 0);
		assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(2), 0);
		assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(3), 0);
		assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(4), 30);
		assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(5), 50);

		// Delete line 1
		whitespaceComputer.onModelLinesDeleted(1, 1);
		// whitespaces: d(2, 30), c(3, 20)
		assert.equal(whitespaceComputer.getCount(), 2);
		assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(0), 2);
		assert.equal(whitespaceComputer.getHeightForWhitespaceIndex(0), 30);
		assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(1), 3);
		assert.equal(whitespaceComputer.getHeightForWhitespaceIndex(1), 20);
		assert.equal(whitespaceComputer.getAccumulatedHeight(0), 30);
		assert.equal(whitespaceComputer.getAccumulatedHeight(1), 50);
		assert.equal(whitespaceComputer.getTotalHeight(), 50);
		assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(1), 0);
		assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(2), 0);
		assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(3), 30);
		assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(4), 50);
		assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(5), 50);

		// Insert a line before line 1
		whitespaceComputer.onModelLinesInserted(1, 1);
		// whitespaces: d(3, 30), c(4, 20)
		assert.equal(whitespaceComputer.getCount(), 2);
		assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(0), 3);
		assert.equal(whitespaceComputer.getHeightForWhitespaceIndex(0), 30);
		assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(1), 4);
		assert.equal(whitespaceComputer.getHeightForWhitespaceIndex(1), 20);
		assert.equal(whitespaceComputer.getAccumulatedHeight(0), 30);
		assert.equal(whitespaceComputer.getAccumulatedHeight(1), 50);
		assert.equal(whitespaceComputer.getTotalHeight(), 50);
		assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(1), 0);
		assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(2), 0);
		assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(3), 0);
		assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(4), 30);
		assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(5), 50);

		// Delete line 4
		whitespaceComputer.onModelLinesDeleted(4, 4);
		// whitespaces: d(3, 30), c(3, 20)
		assert.equal(whitespaceComputer.getCount(), 2);
		assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(0), 3);
		assert.equal(whitespaceComputer.getHeightForWhitespaceIndex(0), 30);
		assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(1), 3);
		assert.equal(whitespaceComputer.getHeightForWhitespaceIndex(1), 20);
		assert.equal(whitespaceComputer.getAccumulatedHeight(0), 30);
		assert.equal(whitespaceComputer.getAccumulatedHeight(1), 50);
		assert.equal(whitespaceComputer.getTotalHeight(), 50);
		assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(1), 0);
		assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(2), 0);
		assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(3), 0);
		assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(4), 50);
		assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(5), 50);
	});
开发者ID:StateFarmIns,项目名称:vscode,代码行数:101,代码来源:whitespaceComputer.test.ts

示例2: onModelLinesDeleted

	/**
	 * Notify the layouter that lines have been deleted (a continuous zone of lines).
	 *
	 * @param fromLineNumber The line number at which the deletion started, inclusive
	 * @param toLineNumber The line number at which the deletion ended, inclusive
	 */
	public onModelLinesDeleted(fromLineNumber:number, toLineNumber:number): void {
		this.linesCount -= (toLineNumber - fromLineNumber + 1);
		this.whitespaces.onModelLinesDeleted(fromLineNumber, toLineNumber);
	}
开发者ID:1424667164,项目名称:vscode,代码行数:10,代码来源:verticalObjects.ts


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