本文整理汇总了TypeScript中vs/editor/contrib/snippet/snippetSession.SnippetSession.insert方法的典型用法代码示例。如果您正苦于以下问题:TypeScript SnippetSession.insert方法的具体用法?TypeScript SnippetSession.insert怎么用?TypeScript SnippetSession.insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/editor/contrib/snippet/snippetSession.SnippetSession
的用法示例。
在下文中一共展示了SnippetSession.insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('snippets, merge', function () {
editor.setSelection(new Selection(1, 1, 1, 1));
const session = new SnippetSession(editor, 'This ${1:is ${2:nested}}.$0');
session.insert();
session.next();
assertSelections(editor, new Selection(1, 9, 1, 15));
session.merge('really ${1:nested}$0');
assertSelections(editor, new Selection(1, 16, 1, 22));
session.next();
assertSelections(editor, new Selection(1, 22, 1, 22));
assert.equal(session.isAtLastPlaceholder, false);
session.next();
assert.equal(session.isAtLastPlaceholder, true);
assertSelections(editor, new Selection(1, 23, 1, 23));
session.prev();
editor.trigger('test', 'type', { text: 'AAA' });
// back to `really ${1:nested}`
session.prev();
assertSelections(editor, new Selection(1, 16, 1, 22));
// back to `${1:is ...}` which now grew
session.prev();
assertSelections(editor, new Selection(1, 6, 1, 25));
});
示例2: test
test('snippets, newline NO whitespace adjust', () => {
editor.setSelection(new Selection(2, 5, 2, 5));
const session = new SnippetSession(editor, 'abc\n foo\n bar\n$0', 0, 0, false);
session.insert();
assert.equal(editor.getModel().getValue(), 'function foo() {\n abc\n foo\n bar\nconsole.log(a);\n}');
});