本文整理匯總了TypeScript中vs/editor/contrib/snippet/common/snippet.CodeSnippet.fromInternal方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript CodeSnippet.fromInternal方法的具體用法?TypeScript CodeSnippet.fromInternal怎麽用?TypeScript CodeSnippet.fromInternal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vs/editor/contrib/snippet/common/snippet.CodeSnippet
的用法示例。
在下文中一共展示了CodeSnippet.fromInternal方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: snippetTest
snippetTest((editor, cursor, codeSnippet, snippetController) => {
editor.setSelections([
new Selection(2, 7, 2, 7),
]);
codeSnippet = CodeSnippet.fromInternal('xo{{}}r');
snippetController.run(codeSnippet, 1, 0, false);
assert.equal(editor.getSelections().length, 1);
assert.ok(editor.getSelection().equalsRange({ startLineNumber: 2, startColumn: 8, endColumn: 8, endLineNumber: 2 }));
});
示例2: withMockCodeEditor
withMockCodeEditor(lines, {}, (editor, cursor) => {
editor.getModel().updateOptions({
insertSpaces: false
});
let snippetController = editor.registerAndInstantiateContribution<TestSnippetController>(TestSnippetController);
let codeSnippet = CodeSnippet.fromInternal([
'for (var {{index}}; {{index}} < {{array}}.length; {{index}}++) {',
'\tvar element = {{array}}[{{index}}];',
'\t{{}}',
'}'
].join('\n'));
cb(editor, cursor, codeSnippet, snippetController);
snippetController.dispose();
});
示例3: assertInternalAndTextmate
function assertInternalAndTextmate(internal: string, textmate: string, callback: (snippet: CodeSnippet) => any) {
callback(CodeSnippet.fromInternal(internal));
callback(CodeSnippet.fromTextmate(textmate));
}