本文整理汇总了TypeScript中vs/editor/contrib/snippet/browser/snippetSession.SnippetSession.insert方法的典型用法代码示例。如果您正苦于以下问题:TypeScript SnippetSession.insert方法的具体用法?TypeScript SnippetSession.insert怎么用?TypeScript SnippetSession.insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/editor/contrib/snippet/browser/snippetSession.SnippetSession
的用法示例。
在下文中一共展示了SnippetSession.insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('snippets, selections -> next/prev', () => {
const session = new SnippetSession(editor, 'f$1oo${2:bar}foo$0');
session.insert();
// @ $2
assertSelections(editor, new Selection(1, 2, 1, 2), new Selection(2, 6, 2, 6));
// @ $1
session.next();
assertSelections(editor, new Selection(1, 4, 1, 7), new Selection(2, 8, 2, 11));
// @ $2
session.prev();
assertSelections(editor, new Selection(1, 2, 1, 2), new Selection(2, 6, 2, 6));
// @ $1
session.next();
assertSelections(editor, new Selection(1, 4, 1, 7), new Selection(2, 8, 2, 11));
// @ $0
session.next();
assertSelections(editor, new Selection(1, 10, 1, 10), new Selection(2, 14, 2, 14));
});
示例2: test
test('snippets, selections & typing', function () {
const session = new SnippetSession(editor, 'f${1:oo}_$2_$0');
session.insert();
editor.trigger('test', 'type', { text: 'X' });
session.next();
editor.trigger('test', 'type', { text: 'bar' });
// go back to ${2:oo} which is now just 'X'
session.prev();
assertSelections(editor, new Selection(1, 2, 1, 3), new Selection(2, 6, 2, 7));
// go forward to $1 which is now 'bar'
session.next();
assertSelections(editor, new Selection(1, 4, 1, 7), new Selection(2, 8, 2, 11));
// go to final tabstop
session.next();
assert.equal(model.getValue(), 'fX_bar_function foo() {\n fX_bar_console.log(a);\n}');
assertSelections(editor, new Selection(1, 8, 1, 8), new Selection(2, 12, 2, 12));
});