本文整理汇总了TypeScript中vs/editor/test/common/editorTestUtils.createTextModel函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createTextModel函数的具体用法?TypeScript createTextModel怎么用?TypeScript createTextModel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了createTextModel函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('Bug 18276:[editor] Indentation broken when selection is empty', () => {
let model = createTextModel(
[
'function baz() {'
].join('\n'),
{
insertSpaces: false,
}
);
withTestCodeEditor(null, { model: model }, (editor, cursor) => {
let indentLinesAction = new IndentLinesAction();
editor.setPosition(new Position(1, 2));
indentLinesAction.run(null, editor);
assert.equal(model.getLineContent(1), '\tfunction baz() {');
assert.deepEqual(editor.getSelection(), new Selection(1, 3, 1, 3));
CoreEditingCommands.Tab.runEditorCommand(null, editor, null);
assert.equal(model.getLineContent(1), '\tf\tunction baz() {');
});
model.dispose();
});
示例2: test
test('normalizeIndentation 1', () => {
let model = createTextModel('',
{
insertSpaces: false
}
);
assert.equal(model.normalizeIndentation('\t'), '\t');
assert.equal(model.normalizeIndentation(' '), '\t');
assert.equal(model.normalizeIndentation(' '), ' ');
assert.equal(model.normalizeIndentation(' '), ' ');
assert.equal(model.normalizeIndentation(' '), ' ');
assert.equal(model.normalizeIndentation(''), '');
assert.equal(model.normalizeIndentation(' \t '), '\t\t');
assert.equal(model.normalizeIndentation(' \t '), '\t ');
assert.equal(model.normalizeIndentation(' \t '), '\t ');
assert.equal(model.normalizeIndentation(' \t'), '\t ');
assert.equal(model.normalizeIndentation('\ta'), '\ta');
assert.equal(model.normalizeIndentation(' a'), '\ta');
assert.equal(model.normalizeIndentation(' a'), ' a');
assert.equal(model.normalizeIndentation(' a'), ' a');
assert.equal(model.normalizeIndentation(' a'), ' a');
assert.equal(model.normalizeIndentation('a'), 'a');
assert.equal(model.normalizeIndentation(' \t a'), '\t\ta');
assert.equal(model.normalizeIndentation(' \t a'), '\t a');
assert.equal(model.normalizeIndentation(' \t a'), '\t a');
assert.equal(model.normalizeIndentation(' \ta'), '\t a');
model.dispose();
});
示例3: testGuessIndentation
function testGuessIndentation(defaultInsertSpaces: boolean, defaultTabSize: number, expectedInsertSpaces: boolean, expectedTabSize: number, text: string[], msg?: string): void {
var m = createTextModel(
text.join('\n'),
{
tabSize: defaultTabSize,
insertSpaces: defaultInsertSpaces,
detectIndentation: true
}
);
var r = m.getOptions();
m.dispose();
assert.equal(r.insertSpaces, expectedInsertSpaces, msg);
assert.equal(r.tabSize, expectedTabSize, msg);
}