本文整理汇总了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
});
示例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
});
示例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);
}