本文整理汇总了TypeScript中vs/editor/common/model/textModel.TextModel.getValue方法的典型用法代码示例。如果您正苦于以下问题:TypeScript TextModel.getValue方法的具体用法?TypeScript TextModel.getValue怎么用?TypeScript TextModel.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/editor/common/model/textModel.TextModel
的用法示例。
在下文中一共展示了TextModel.getValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('snippets, selections and snippet ranges', function () {
const session = new SnippetSession(editor, '${1:foo}farboo${2:bar}$0');
session.insert();
assert.equal(model.getValue(), 'foofarboobarfunction foo() {\n foofarboobarconsole.log(a);\n}');
assertSelections(editor, new Selection(1, 1, 1, 4), new Selection(2, 5, 2, 8));
assert.equal(session.isSelectionWithinPlaceholders(), true);
editor.setSelections([new Selection(1, 1, 1, 1)]);
assert.equal(session.isSelectionWithinPlaceholders(), false);
editor.setSelections([new Selection(1, 6, 1, 6), new Selection(2, 10, 2, 10)]);
assert.equal(session.isSelectionWithinPlaceholders(), false); // in snippet, outside placeholder
editor.setSelections([new Selection(1, 6, 1, 6), new Selection(2, 10, 2, 10), new Selection(1, 1, 1, 1)]);
assert.equal(session.isSelectionWithinPlaceholders(), false); // in snippet, outside placeholder
editor.setSelections([new Selection(1, 6, 1, 6), new Selection(2, 10, 2, 10), new Selection(2, 20, 2, 21)]);
assert.equal(session.isSelectionWithinPlaceholders(), false);
// reset selection to placeholder
session.next();
assert.equal(session.isSelectionWithinPlaceholders(), true);
assertSelections(editor, new Selection(1, 10, 1, 13), new Selection(2, 14, 2, 17));
// reset selection to placeholder
session.next();
assert.equal(session.isSelectionWithinPlaceholders(), true);
assert.equal(session.isAtLastPlaceholder, true);
assertSelections(editor, new Selection(1, 13, 1, 13), new Selection(2, 17, 2, 17));
});
示例2: assertOneDirectionLineMapping
function assertOneDirectionLineMapping(model: TextModel, direction: AssertDocumentLineMappingDirection, msg: string): void {
let allText = model.getValue();
let line = 1, column = 1, previousIsCarriageReturn = false;
for (let offset = 0; offset <= allText.length; offset++) {
// The position coordinate system cannot express the position between \r and \n
let position = new Position(line, column + (previousIsCarriageReturn ? -1 : 0));
if (direction === AssertDocumentLineMappingDirection.OffsetToPosition) {
let actualPosition = model.getPositionAt(offset);
assert.equal(actualPosition.toString(), position.toString(), msg + ' - getPositionAt mismatch for offset ' + offset);
} else {
// The position coordinate system cannot express the position between \r and \n
let expectedOffset = offset + (previousIsCarriageReturn ? -1 : 0);
let actualOffset = model.getOffsetAt(position);
assert.equal(actualOffset, expectedOffset, msg + ' - getOffsetAt mismatch for position ' + position.toString());
}
if (allText.charAt(offset) === '\n') {
line++;
column = 1;
} else {
column++;
}
previousIsCarriageReturn = (allText.charAt(offset) === '\r');
}
}
示例3: test
test('snippets, transform', function () {
editor.getModel()!.setValue('');
editor.setSelection(new Selection(1, 1, 1, 1));
const session = new SnippetSession(editor, '${1/foo/bar/}$0');
session.insert();
assertSelections(editor, new Selection(1, 1, 1, 1));
editor.trigger('test', 'type', { text: 'foo' });
session.next();
assert.equal(model.getValue(), 'bar');
assert.equal(session.isAtLastPlaceholder, true);
assertSelections(editor, new Selection(1, 4, 1, 4));
});