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


TypeScript WhitespaceComputer.insertWhitespace方法代碼示例

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


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

示例1: test

	test('WhitespaceComputer Bug', () => {
		var whitespaceComputer = new WhitespaceComputer();

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

		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(0), a); // 0
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(1), b); // 7

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

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

		var d = whitespaceComputer.insertWhitespace(2, 0, 1);
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(0), a); // 0
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(1), d); // 2
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(2), c); // 3
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(3), b); // 7

		var e = whitespaceComputer.insertWhitespace(8, 0, 1);
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(0), a); // 0
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(1), d); // 2
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(2), c); // 3
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(3), b); // 7
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(4), e); // 8

		var f = whitespaceComputer.insertWhitespace(11, 0, 1);
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(0), a); // 0
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(1), d); // 2
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(2), c); // 3
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(3), b); // 7
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(4), e); // 8
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(5), f); // 11

		var g = whitespaceComputer.insertWhitespace(10, 0, 1);
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(0), a); // 0
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(1), d); // 2
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(2), c); // 3
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(3), b); // 7
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(4), e); // 8
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(5), g); // 10
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(6), f); // 11

		var h = whitespaceComputer.insertWhitespace(0, 0, 1);
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(0), a); // 0
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(1), h); // 0
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(2), d); // 2
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(3), c); // 3
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(4), b); // 7
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(5), e); // 8
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(6), g); // 10
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(7), f); // 11
	});
開發者ID:StateFarmIns,項目名稱:vscode,代碼行數:55,代碼來源:whitespaceComputer.test.ts

示例2: test

	test('WhitespaceComputer Bug', () => {
		let whitespaceComputer = new WhitespaceComputer();

		let a = whitespaceComputer.insertWhitespace(0, 0, 1, 0);
		let b = whitespaceComputer.insertWhitespace(7, 0, 1, 0);

		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(0), a); // 0
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(1), b); // 7

		let c = whitespaceComputer.insertWhitespace(3, 0, 1, 0);

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

		let d = whitespaceComputer.insertWhitespace(2, 0, 1, 0);
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(0), a); // 0
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(1), d); // 2
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(2), c); // 3
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(3), b); // 7

		let e = whitespaceComputer.insertWhitespace(8, 0, 1, 0);
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(0), a); // 0
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(1), d); // 2
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(2), c); // 3
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(3), b); // 7
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(4), e); // 8

		let f = whitespaceComputer.insertWhitespace(11, 0, 1, 0);
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(0), a); // 0
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(1), d); // 2
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(2), c); // 3
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(3), b); // 7
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(4), e); // 8
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(5), f); // 11

		let g = whitespaceComputer.insertWhitespace(10, 0, 1, 0);
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(0), a); // 0
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(1), d); // 2
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(2), c); // 3
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(3), b); // 7
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(4), e); // 8
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(5), g); // 10
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(6), f); // 11

		let h = whitespaceComputer.insertWhitespace(0, 0, 1, 0);
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(0), a); // 0
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(1), h); // 0
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(2), d); // 2
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(3), c); // 3
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(4), b); // 7
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(5), e); // 8
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(6), g); // 10
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(7), f); // 11
	});
開發者ID:AllureFer,項目名稱:vscode,代碼行數:55,代碼來源:whitespaceComputer.test.ts

示例3: insertWhitespace

	/**
	 * Insert a new whitespace of a certain height after a line number.
	 * The whitespace has a "sticky" characteristic.
	 * Irrespective of edits above or below `afterLineNumber`, the whitespace will follow the initial line.
	 *
	 * @param afterLineNumber The conceptual position of this whitespace. The whitespace will follow this line as best as possible even when deleting/inserting lines above/below.
	 * @param heightInPx The height of the whitespace, in pixels.
	 * @return An id that can be used later to mutate or delete the whitespace
	 */
	public insertWhitespace(afterLineNumber:number, ordinal:number, heightInPx:number): number {
		return this.whitespaces.insertWhitespace(afterLineNumber, ordinal, heightInPx);
	}
開發者ID:1424667164,項目名稱:vscode,代碼行數:12,代碼來源:verticalObjects.ts


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