本文整理匯總了TypeScript中vs/editor/common/viewLayout/linesLayout.LinesLayout.getVerticalOffsetForWhitespaceIndex方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript LinesLayout.getVerticalOffsetForWhitespaceIndex方法的具體用法?TypeScript LinesLayout.getVerticalOffsetForWhitespaceIndex怎麽用?TypeScript LinesLayout.getVerticalOffsetForWhitespaceIndex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vs/editor/common/viewLayout/linesLayout.LinesLayout
的用法示例。
在下文中一共展示了LinesLayout.getVerticalOffsetForWhitespaceIndex方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: test
test('LinesLayout 1', () => {
// Start off with 10 lines
let linesLayout = new LinesLayout(10, 10);
// lines: [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
// whitespace: -
assert.equal(linesLayout.getLinesTotalHeight(), 100);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(1), 0);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(2), 10);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(3), 20);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(4), 30);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(5), 40);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(6), 50);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(7), 60);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(8), 70);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(9), 80);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(10), 90);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(0), 1);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(1), 1);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(5), 1);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(9), 1);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(10), 2);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(11), 2);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(15), 2);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(19), 2);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(20), 3);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(21), 3);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(29), 3);
// Add whitespace of height 5px after 2nd line
linesLayout.insertWhitespace(2, 0, 5, 0);
// lines: [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
// whitespace: a(2,5)
assert.equal(linesLayout.getLinesTotalHeight(), 105);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(1), 0);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(2), 10);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(3), 25);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(4), 35);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(5), 45);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(0), 1);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(1), 1);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(9), 1);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(10), 2);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(20), 3);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(21), 3);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(24), 3);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(25), 3);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(35), 4);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(45), 5);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(104), 10);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(105), 10);
// Add two more whitespaces of height 5px
linesLayout.insertWhitespace(3, 0, 5, 0);
linesLayout.insertWhitespace(4, 0, 5, 0);
// lines: [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
// whitespace: a(2,5), b(3, 5), c(4, 5)
assert.equal(linesLayout.getLinesTotalHeight(), 115);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(1), 0);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(2), 10);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(3), 25);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(4), 40);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(5), 55);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(6), 65);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(0), 1);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(1), 1);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(9), 1);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(10), 2);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(19), 2);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(20), 3);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(34), 3);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(35), 4);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(49), 4);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(50), 5);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(64), 5);
assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(65), 6);
assert.equal(linesLayout.getVerticalOffsetForWhitespaceIndex(0), 20); // 20 -> 25
assert.equal(linesLayout.getVerticalOffsetForWhitespaceIndex(1), 35); // 35 -> 40
assert.equal(linesLayout.getVerticalOffsetForWhitespaceIndex(2), 50);
assert.equal(linesLayout.getWhitespaceIndexAtOrAfterVerticallOffset(0), 0);
assert.equal(linesLayout.getWhitespaceIndexAtOrAfterVerticallOffset(19), 0);
assert.equal(linesLayout.getWhitespaceIndexAtOrAfterVerticallOffset(20), 0);
assert.equal(linesLayout.getWhitespaceIndexAtOrAfterVerticallOffset(21), 0);
assert.equal(linesLayout.getWhitespaceIndexAtOrAfterVerticallOffset(22), 0);
assert.equal(linesLayout.getWhitespaceIndexAtOrAfterVerticallOffset(23), 0);
assert.equal(linesLayout.getWhitespaceIndexAtOrAfterVerticallOffset(24), 0);
assert.equal(linesLayout.getWhitespaceIndexAtOrAfterVerticallOffset(25), 1);
assert.equal(linesLayout.getWhitespaceIndexAtOrAfterVerticallOffset(26), 1);
assert.equal(linesLayout.getWhitespaceIndexAtOrAfterVerticallOffset(34), 1);
assert.equal(linesLayout.getWhitespaceIndexAtOrAfterVerticallOffset(35), 1);
assert.equal(linesLayout.getWhitespaceIndexAtOrAfterVerticallOffset(36), 1);
assert.equal(linesLayout.getWhitespaceIndexAtOrAfterVerticallOffset(39), 1);
assert.equal(linesLayout.getWhitespaceIndexAtOrAfterVerticallOffset(40), 2);
assert.equal(linesLayout.getWhitespaceIndexAtOrAfterVerticallOffset(41), 2);
//.........這裏部分代碼省略.........