本文整理汇总了TypeScript中vs/editor/common/viewLayout/linesLayout.LinesLayout.onModelLinesDeleted方法的典型用法代码示例。如果您正苦于以下问题:TypeScript LinesLayout.onModelLinesDeleted方法的具体用法?TypeScript LinesLayout.onModelLinesDeleted怎么用?TypeScript LinesLayout.onModelLinesDeleted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/editor/common/viewLayout/linesLayout.LinesLayout
的用法示例。
在下文中一共展示了LinesLayout.onModelLinesDeleted方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('LinesLayout 2', () => {
// Start off with 10 lines and one whitespace after line 2, of height 5
var linesLayout = new LinesLayout(10, 1);
var a = linesLayout.insertWhitespace(2, 0, 5);
// 10 lines
// whitespace: - a(2,5)
assert.equal(linesLayout.getLinesTotalHeight(), 15);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(1), 0);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(2), 1);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(3), 7);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(4), 8);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(5), 9);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(6), 10);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(7), 11);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(8), 12);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(9), 13);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(10), 14);
// Change whitespace height
// 10 lines
// whitespace: - a(2,10)
linesLayout.changeWhitespace(a, 2, 10);
assert.equal(linesLayout.getLinesTotalHeight(), 20);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(1), 0);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(2), 1);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(3), 12);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(4), 13);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(5), 14);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(6), 15);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(7), 16);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(8), 17);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(9), 18);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(10), 19);
// Change whitespace position
// 10 lines
// whitespace: - a(5,10)
linesLayout.changeWhitespace(a, 5, 10);
assert.equal(linesLayout.getLinesTotalHeight(), 20);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(1), 0);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(2), 1);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(3), 2);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(4), 3);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(5), 4);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(6), 15);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(7), 16);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(8), 17);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(9), 18);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(10), 19);
// Pretend that lines 5 and 6 were deleted
// 8 lines
// whitespace: - a(4,10)
linesLayout.onModelLinesDeleted(5, 6);
assert.equal(linesLayout.getLinesTotalHeight(), 18);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(1), 0);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(2), 1);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(3), 2);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(4), 3);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(5), 14);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(6), 15);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(7), 16);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(8), 17);
// Insert two lines at the beginning
// 10 lines
// whitespace: - a(6,10)
linesLayout.onModelLinesInserted(1, 2);
assert.equal(linesLayout.getLinesTotalHeight(), 20);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(1), 0);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(2), 1);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(3), 2);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(4), 3);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(5), 4);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(6), 5);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(7), 16);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(8), 17);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(9), 18);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(10), 19);
// Remove whitespace
// 10 lines
linesLayout.removeWhitespace(a);
assert.equal(linesLayout.getLinesTotalHeight(), 10);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(1), 0);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(2), 1);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(3), 2);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(4), 3);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(5), 4);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(6), 5);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(7), 6);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(8), 7);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(9), 8);
assert.equal(linesLayout.getVerticalOffsetForLineNumber(10), 9);
});